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
Running Kubernetes in the Browser. Yes, really. Not really. Kind of.
nateabele
1
12
Un-dux Your Front-End
nateabele
1
94
CloudFormation For Fun & Profit (But Mostly Sanity)
nateabele
0
61
Functional Reactive Systems
nateabele
1
140
ngPittsburgh - AngularUI Router Philosophy
nateabele
1
1k
The Future of Programming
nateabele
1
440
Past, Present, and Future: The Evolution of PHP Development
nateabele
1
490
The Future of Programming: PHP Argentina 2014
nateabele
1
110
Designing Hypermedia APIs
nateabele
4
620
Other Decks in Programming
See All in Programming
KSPの導入・移行を前向きに検討しよう!
shxun6934
PRO
0
290
React + TextAliveでカッコいいLyric Applicatioinを作ろう!!
tosuri13
0
400
Kotlin 2.0 and Beyond
antonarhipov
2
150
Findy - エンジニア向け会社紹介 / Findy Letter for Engineers
findyinc
4
90k
Amazon Neptuneで始める初めてのグラフDB ー グラフDBを使う意味を考える ー
satoshi256kbyte
2
260
Method Swizzlingを行うライブラリにおけるマルチモジュール設計
yoshikma
0
120
Crafting Cross-Platform Adventures: Building a Game Engine with Kotlin Multiplatform
dwursteisen
0
220
Composing an API the *right* way (Droidcon New York 2024)
zsmb
2
190
サーバーレスで負荷試験!Step Functions + Lambdaを使ったk6の分散実行
shuntakahashi
6
1.6k
Prompt Cachingは本当に効果的なのか検証してみた.pdf
ttnyt8701
0
540
Architecture Decision Record (ADR)
nearme_tech
PRO
1
700
Regular Expressions, REXML, Automata Learning
makenowjust
0
220
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
36
7k
Code Reviewing Like a Champion
maltzj
517
39k
Embracing the Ebb and Flow
colly
83
4.4k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
278
13k
The Art of Programming - Codeland 2020
erikaheidi
48
13k
Building Better People: How to give real-time feedback that sticks.
wjessup
359
19k
Agile that works and the tools we love
rasmusluckow
327
20k
Making the Leap to Tech Lead
cromwellryan
128
8.8k
Automating Front-end Workflow
addyosmani
1365
200k
Speed Design
sergeychernyshev
22
430
Optimizing for Happiness
mojombo
375
69k
Large-scale JavaScript Application Architecture
addyosmani
508
110k
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