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
89
CloudFormation For Fun & Profit (But Mostly Sanity)
nateabele
0
57
Functional Reactive Systems
nateabele
1
130
ngPittsburgh - AngularUI Router Philosophy
nateabele
1
940
The Future of Programming
nateabele
1
380
Past, Present, and Future: The Evolution of PHP Development
nateabele
1
410
The Future of Programming: PHP Argentina 2014
nateabele
1
97
Designing Hypermedia APIs
nateabele
4
600
The Future
nateabele
0
150
Other Decks in Programming
See All in Programming
Deno に Web 標準 API を実装する / Implementing Web Standard API to Deno
petamoriken
0
310
Kotlinを用いたDSL的な設計手法と使用上の注意
kohii00
2
490
Jakarta EE 11 - Performance and Developer Productivity
ivargrimstad
0
850
ISUCONってなんだか難しそう……!!でも、初めてのISUCONにPHPで挑戦してきました!
kotomin_m
0
260
Flutterアプリを GitHub Actions & Xcode Cloud で社内配布する / Distribute Flutter apps internally
takasfz
0
130
孤独のCTOグルメという やや奇抜な企画をやった目的と効果
shoheimitani
3
730
Reckoner の Scala プロジェクトにおける オブザーバビリティの取り組み / Observability Initiatives in Reckoner's Scala Project
nomadblacky
0
820
TokyoR#111_ANOVA
kilometer
1
710
ここ1~2年くらいで 使えるようになった(主要ブラウザーの最新版 がすべて対応した ) ウェブの新機能について ランダムに喋る!
myzkyy
7
5.9k
Laravel標準バリデーションでできること
hmb_ok
1
330
PHP8の機能を使って堅牢にコードを書く
fendo181
6
2k
マイ隙間家具OSSたちのご紹介
karupanerura
2
130
Featured
See All Featured
Music & Morning Musume
bryan
39
5.4k
Making the Leap to Tech Lead
cromwellryan
122
8.4k
Atom: Resistance is Futile
akmur
258
25k
Code Review Best Practice
trishagee
54
15k
How STYLIGHT went responsive
nonsquared
92
4.7k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
11
1.4k
Producing Creativity
orderedlist
PRO
335
39k
Designing on Purpose - Digital PM Summit 2013
jponch
109
6.4k
BBQ
matthewcrist
78
8.7k
Faster Mobile Websites
deanohume
296
30k
Pencils Down: Stop Designing & Start Developing
hursman
115
11k
What the flash - Photography Introduction
edds
64
11k
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