$30 off During Our Annual Pro Sale. View Details »

API design and more

Jordi Romero
December 02, 2011

API design and more

Talk about API design, implementation, deployment and scaling, with special emphasis on the design. Go grab a beer and enjoy the presentation :)

API Design http://jrom.net/api-design-and-more post including video of the talk.

Jordi Romero

December 02, 2011
Tweet

More Decks by Jordi Romero

Other Decks in Programming

Transcript

  1. API

  2. HTTP HyperText Transfer Protocol - OSI lvl 7 learn to

    love it use proper URIs, methods, status codes, request and response headers, ...
  3. REST REpresentational State Transfer Resources are first class citizens Resources

    have unique representations Communication is stateless
  4. HTTP methods GET POST PUT DELETE HEAD PATCH ... Also

    called “Verbs” Together with a URI they tell the API what to do
  5. GET HEAD PUT POST DELETE PATCH retrieve a resource representation

    get only the headers, no body update a resource create a resource, execute controllers remove a resource partially update a resource more...
  6. Response statuses 1xx 2xx 3xx 4xx 5xx Do not limit

    to 200, 404 and 500 RTFM Specifications
  7. Metadata Useful req/res information in the headers Content-Type Content-Length Last-Modified

    Etag Location Cache-Control Expires Date Pragma Custom, ...
  8. Metadata Useful req/res information in the headers Content-Type Content-Length Last-Modified

    Etag Location Cache-Control Expires Date Pragma Custom, ... MORE ON THAT LATER
  9. Security Protect private resources OAuth is the most common option

    right now Basic HTTP Authentication also works SSL is not optional
  10. stateless processes any process is good Sessions can go to

    Redis, Memcached, ... State must go on stateful processes (database)
  11. horizontal scaling is inexpensive not really If more load can

    be handled by more processes: it scales!
  12. application caching don’t do things twice Never calculate things twice.

    Do it once, store it. Redis, Memcached, I’m looking at you.
  13. HTTP caching save bandwidth, cut response time Use HTTP headers

    to define the response’s cacheability, expiration, validity, ... Take advantage of Varnish, Squid, ...
  14. database replication faster reads is a big win If your

    API serves more reads than writes, send the reads to read-only slaves of the database