Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Best Practice in API Design

Best Practice in API Design

API theory and some design pointers for my talk at Hackference 2013 in Birmingham

Lorna Mitchell

August 30, 2013
Tweet

More Decks by Lorna Mitchell

Other Decks in Technology

Transcript

  1. About Me • Lorna Jane Mitchell • http://lornajane.net • API

    and Web Development Consultant • Author, speaker
  2. 3 Stages of API Development There are various stages of

    building an API 1. Publish an API 2. Consume your own API 3. Modular/Multiple APIs
  3. Web

  4. Web

  5. Status Codes: Headline News Common codes: 200 OK 304 Not

    Modified 302 Found 301 Moved 401 Not Authorised 403 Forbidden 404 Not Found 500 Internal Server Error
  6. HTTP Headers Headers are the metadata about the content we

    send/receive Useful headers: • Accept and Content-Type: used for content format negotiation
  7. HTTP Headers Headers are the metadata about the content we

    send/receive Useful headers: • Accept and Content-Type: used for content format negotiation • User-Agent: to identify what made the request
  8. HTTP Headers Headers are the metadata about the content we

    send/receive Useful headers: • Accept and Content-Type: used for content format negotiation • User-Agent: to identify what made the request • Set-Cookie and Cookie: working with cookie data
  9. HTTP Headers Headers are the metadata about the content we

    send/receive Useful headers: • Accept and Content-Type: used for content format negotiation • User-Agent: to identify what made the request • Set-Cookie and Cookie: working with cookie data • Authorization: controlling access
  10. HTTP Verbs • More than GET and POST • PUT

    and DELETE to update and delete in a RESTful service • HEAD, OPTIONS and others also specified In REST, we use: GET Read POST Create PUT Update DELETE Delete
  11. RPC: Remote Procedure Call • Single endpoint • Function name

    • Parameters • Return value • SOAP is a kind of RPC
  12. RESTful Services • REpresentational State Transfer • URLs are unique

    resource identifiers • HTTP verbs indicate which operation should happen • We have full CRUD operations on a series of resources