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
200
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
Running Kubernetes in the Browser. Yes, really. Not really. Kind of.
nateabele
1
33
Un-dux Your Front-End
nateabele
1
100
CloudFormation For Fun & Profit (But Mostly Sanity)
nateabele
0
72
Functional Reactive Systems
nateabele
1
140
ngPittsburgh - AngularUI Router Philosophy
nateabele
1
1.1k
The Future of Programming
nateabele
1
500
Past, Present, and Future: The Evolution of PHP Development
nateabele
1
560
The Future of Programming: PHP Argentina 2014
nateabele
1
120
Designing Hypermedia APIs
nateabele
4
660
Other Decks in Programming
See All in Programming
一緒に働きたくなるプログラマの思想 #QiitaConference
mu_zaru
76
18k
プロフェッショナルとしての成長「問題の深掘り」が導く真のスキルアップ / issue-analysis-and-skill-up
minodriven
8
1.8k
KawaiiLT 登壇資料 キャリアとモチベーション
hiiragi
0
160
Bedrock×MCPで社内ブログ執筆文化を育てたい!
har1101
6
1.2k
Exit 8 for SwiftUI
ojun9
0
140
サービスクラスのありがたみを発見したときの思い出 #phpcon_odawara
77web
4
700
Cursorを活用したAIプログラミングについて 入門
rect
0
110
メモリウォールを超えて:キャッシュメモリ技術の進歩
kawayu
0
1.9k
小田原でみんなで一句詠みたいな #phpcon_odawara
stefafafan
0
350
On-the-fly Suggestions of Rewriting Method Deprecations
ohbarye
1
3.8k
Dissecting and Reconstructing Ruby Syntactic Structures
ydah
2
1.3k
SwiftDataのカスタムデータストアを試してみた
1mash0
0
130
Featured
See All Featured
[RailsConf 2023] Rails as a piece of cake
palkan
54
5.5k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
178
53k
For a Future-Friendly Web
brad_frost
177
9.7k
Typedesign – Prime Four
hannesfritz
41
2.6k
Embracing the Ebb and Flow
colly
85
4.7k
Rails Girls Zürich Keynote
gr2m
94
13k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
14
1.4k
Code Reviewing Like a Champion
maltzj
523
40k
How to Ace a Technical Interview
jacobian
276
23k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
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