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

REST API Design, Part II

REST API Design, Part II

Given at PHP Undiscovered, SF.

Nate Abele

August 30, 2013
Tweet

More Decks by Nate Abele

Other Decks in Programming

Transcript

  1. How to Future-Proof & Increase The Level of Sanity in

    the Design of Your APIs, by Respecting the Best Practices of HTTP Or...
  2. Auth •Simple! •Basic vs. Digest (over SSL, obviously) •Upshot of

    Basic: http://user:[email protected]/objects •Cookies? •Custom Tokens?
  3. Querying •There are approaches to making this discoverable •They are

    ridiculously ivory-tower •Better: ?q=<whatever>
  4. Relationships GET /tasks HTTP/1.1 [{ title: "Finish client demo", completed:

    false, _links: { self: { href: "http://my.app/tasks/1138" }, owner: { href: "http://my.app/users/nate" }, subtasks: { href: "http://my.app/tasks/1138/subtasks" } } }]
  5. Caching (Strategies) • Generated cache keys (ETag, If-None-Match) • For

    writes: If-Match • Time-based (Last-Modified / If-Modified-Since)
  6. Logging X-Query-Log: SELECT * From users WHERE name = "nate"

    X-Query-Log: SELECT * From tasks WHERE user_id = 13