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
Open Source Swiftc Workshop
kitasuke
1
180
Creating Retro-Style Photos Using Swift
ski
1
340
「コンパイル時のユニットテスト」導入するとユニットテストを 書かなくてよくなるのか?
tomohisa
9
2.2k
phpunit/php-code-coverageって何をしてるんだ #phperkaigi
o0h
PRO
2
220
Laravel標準バリデーションでできること
hmb_ok
2
360
Material 3で Material 2ぽい見た目にする
numeroanddev
2
250
イベントストーミングによるオブジェクトモデリング・オブジェクト指向プログラミングの適用・開発プロセスの変遷・アーキテクチャの変革 / Object modeling with Event Storming.
nrslib
12
2.9k
OpenTelemetry のサービスという概念について
azukiazusa1
1
390
SwiftUI, Jetpack Composeの導入で変化した「家族アルバム みてね」のアプリ開発体験
hicka04
6
390
ファイル先頭の use の意味、説明できますか? 〜PHP の namespace と autoloading の関係を正しく理解しよう〜 / namespace and autoloading in php
okashoi
2
470
Parallel Socket Communication in Swift
s_shimotori
0
220
受託開発でGitLab CI を活用していく
xiombatsg
1
100
Featured
See All Featured
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
28
5.9k
Faster Mobile Websites
deanohume
296
30k
Bootstrapping a Software Product
garrettdimon
PRO
302
110k
Making the Leap to Tech Lead
cromwellryan
122
8.4k
Code Reviewing Like a Champion
maltzj
512
39k
jQuery: Nuts, Bolts and Bling
dougneiner
57
7.1k
Designing on Purpose - Digital PM Summit 2013
jponch
109
6.4k
Fireside Chat
paigeccino
19
2.6k
The Mythical Team-Month
searls
214
42k
Git: the NoSQL Database
bkeepers
PRO
421
63k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
225
51k
Build The Right Thing And Hit Your Dates
maggiecrowley
23
1.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