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
220
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
62
Un-dux Your Front-End
nateabele
1
140
CloudFormation For Fun & Profit (But Mostly Sanity)
nateabele
0
82
Functional Reactive Systems
nateabele
1
170
ngPittsburgh - AngularUI Router Philosophy
nateabele
1
1.1k
The Future of Programming
nateabele
1
560
Past, Present, and Future: The Evolution of PHP Development
nateabele
1
620
The Future of Programming: PHP Argentina 2014
nateabele
1
130
Designing Hypermedia APIs
nateabele
4
710
Other Decks in Programming
See All in Programming
オブザーバビリティ駆動開発って実際どうなの?
yohfee
1
110
15年目のiOSアプリを1から作り直す技術
teakun
0
480
CSC307 Lecture 06
javiergs
PRO
0
700
iOSアプリでフロントエンドと仲良くする
ryunakayama
0
120
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
270
「ブロックテーマでは再現できない」は本当か?
inc2734
0
1.1k
AIと一緒にレガシーに向き合ってみた
nyafunta9858
0
420
FOSDEM 2026: STUNMESH-go: Building P2P WireGuard Mesh Without Self-Hosted Infrastructure
tjjh89017
0
190
DSPy入門 Pythonで実現する自動プロンプト最適化 〜人手によるプロンプト調整からの卒業〜
seaturt1e
1
190
文字コードの話
qnighy
36
14k
その「common」ディレクトリ、腐っていませんか?
kinocoboy2
1
110
izumin5210のプロポーザルのネタ探し #tskaigi_msup
izumin5210
1
420
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
55
9.5k
Code Review Best Practice
trishagee
74
20k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
210
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
66
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Docker and Python
trallard
47
3.7k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
84
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Deep Space Network (abreviated)
tonyrice
0
75
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
750
Scaling GitHub
holman
464
140k
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