Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
REST API Design, Part II
Search
Nate Abele
August 30, 2013
Programming
1
190
REST API Design, Part II
Given at PHP Undiscovered, SF.
Nate Abele
August 30, 2013
Tweet
Share
More Decks by Nate Abele
See All by Nate Abele
Un-dux Your Front-End
nateabele
1
90
CloudFormation For Fun & Profit (But Mostly Sanity)
nateabele
0
57
Functional Reactive Systems
nateabele
1
130
ngPittsburgh - AngularUI Router Philosophy
nateabele
1
950
The Future of Programming
nateabele
1
390
Past, Present, and Future: The Evolution of PHP Development
nateabele
1
430
The Future of Programming: PHP Argentina 2014
nateabele
1
100
Designing Hypermedia APIs
nateabele
4
600
The Future
nateabele
0
150
Other Decks in Programming
See All in Programming
検証も兼ねて個人開発でHonoとかと向き合った話
hanetsuki
1
1.3k
Java 22 Overview
kishida
1
190
AppRouter Panel Talk
yosuke_furukawa
PRO
1
450
Komplexe Oberflächen mit SVG und der Web Animation API
joergneumann
0
680
Polars入門
daikikatsuragawa
1
160
R言語の環境構築と基礎 Tokyo.R 112
bob3bob3
0
280
はてなにおける CSS Modules、及び CSS Modules に足りないもの / CSS Modules in Hatena, and CSS Modules missing parts
mizdra
7
970
Apache Hive 4 on Treasure Data
ryukobayashi
1
410
Site Reliability Engineering for GMO
pyama86
8
1.1k
Git Lint
bkuhlmann
4
760
敵対的ポイフル
futabato
0
130
Try creating your own orderedmap
kazamori
1
170
Featured
See All Featured
A better future with KSS
kneath
231
16k
Bootstrapping a Software Product
garrettdimon
PRO
302
110k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
126
32k
Imperfection Machines: The Place of Print at Facebook
scottboms
261
12k
Faster Mobile Websites
deanohume
300
30k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
79
43k
Facilitating Awesome Meetings
lara
43
5.6k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
12
1.5k
jQuery: Nuts, Bolts and Bling
dougneiner
59
7.2k
Testing 201, or: Great Expectations
jmmastey
29
6.4k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
117
18k
For a Future-Friendly Web
brad_frost
172
9k
Transcript
The Dream of the 90’s is Withering on the Vine
(in Portland)
How to Future-Proof & Increase The Level of Sanity in
the Design of Your APIs, by Respecting the Best Practices of HTTP Or...
This is Roy
Principles • Client-Server • Stateless • Cacheable • Uniform Interface
• Opaque Layering • Code-on-Demand
Objectives •Auth •Querying •Relationships •Pagination •Formats •Caching •Logging •API Versioning
Auth •Simple! •Basic vs. Digest (over SSL, obviously) •Upshot of
Basic: http://user:
[email protected]
/objects •Cookies? •Custom Tokens?
Querying •There are approaches to making this discoverable •They are
ridiculously ivory-tower •Better: ?q=<whatever>
Relationships •Goal: Introspect API domain model and transform object relationships
to URLs
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" } } }]
Pagination GET /tasks?page=5&order=due ?
Pagination HTTP Range! GET /videos/rickroll.mp4 Range: bytes=100-99999
Pagination HEAD /tasks HTTP/1.1 ... HTTP 200 OK Accept-Ranges: tasks
Pagination HEAD /posts HTTP/1.1 ... HTTP 200 OK Accept-Ranges: posts
Pagination GET /posts HTTP/1.1 Range: posts=1-20
Caching (Strategies) • Generated cache keys (ETag, If-None-Match) • For
writes: If-Match • Time-based (Last-Modified / If-Modified-Since)
Logging Custom Response Headers!
Logging X-Query-Log: SELECT * From users WHERE name = "nate"
X-Query-Log: SELECT * From tasks WHERE user_id = 13
Logging X-Query-Log: users.find({ name: "nate" })
DEMO