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
HTTP API Design for iOS Applications
Search
Patrick Van Stee
August 16, 2013
Programming
11
570
HTTP API Design for iOS Applications
Patrick Van Stee
August 16, 2013
Tweet
Share
More Decks by Patrick Van Stee
See All by Patrick Van Stee
Raft: Consensus for Rubyists
vanstee
137
6.7k
Elixir and Ecto
vanstee
5
860
Bootstrap
vanstee
8
730
Consensus: An Introduction to Raft
vanstee
22
2.8k
Convergent Replicated Data Types
vanstee
4
700
Pour Over Brewing Method
vanstee
1
310
Celluloid & DCell
vanstee
4
500
Map Reduce & Ruby
vanstee
10
730
Other Decks in Programming
See All in Programming
各クラウドサービスにおける.NETの対応と見解
ymd65536
0
150
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
4
320
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
140
선언형 UI에서의 상태관리
l2hyunwoo
0
180
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
210
命名をリントする
chiroruxx
1
430
PHPで学ぶプログラミングの教訓 / Lessons in Programming Learned through PHP
nrslib
3
340
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
120
Haze - Real time background blurring
chrisbanes
1
520
17年周年のWebアプリケーションにTanStack Queryを導入する / Implementing TanStack Query in a 17th Anniversary Web Application
saitolume
0
250
Webエンジニア主体のモバイルチームの 生産性を高く保つためにやったこと
igreenwood
0
340
責務を分離するための例外設計 - PHPカンファレンス 2024
kajitack
8
1.8k
Featured
See All Featured
We Have a Design System, Now What?
morganepeng
51
7.3k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Designing for Performance
lara
604
68k
Designing for humans not robots
tammielis
250
25k
Learning to Love Humans: Emotional Interface Design
aarron
274
40k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
How STYLIGHT went responsive
nonsquared
96
5.2k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Unsuck your backbone
ammeep
669
57k
Rails Girls Zürich Keynote
gr2m
94
13k
Being A Developer After 40
akosma
87
590k
Practical Orchestrator
shlominoach
186
10k
Transcript
HTTP API Design for iOS Applications
@vanstee Big Nerd Ranch
• Modeling Resources • Tools: Server and Client • Real
world problems • Future
Modeling Resources
The key abstraction of information in REST is a resource.
re·source /ˈrēˌsôrs/ A resource is a conceptual mapping to a
set of entities, not the entity that corresponds to the mapping at any particular point in time.
Resources are not just database records
Resources are the nouns. HTTP methods are the verbs. URIs
are the identifiers. Media types are the representations.
But what about transactions? searches? complex actions?
Don’t do this: POST /accounts/1/transfer/500.00/to/2 Try this instead: POST /transactions
{ “from”: 1, “to”: 2, “amount”: 500.00 }
Tools
Server-side • Rails • Active Model Serializers • Custom Responders
• rack-test and json_spec
Client-side • AFNetworking • RestKit (if you really need it)
• VCRURLConnection and mitmproxy
Real World Problems
Versioning Don’t do this: POST /v1/users/1 Try this instead: POST
/users/1 Accept: application/json; version=1.0
Authentication • OAuth2 with API routes for token generation •
NSURLConnection supports cookies • Basic Authentication over HTTPS*
Caching • NSURLCache has support for Cache-Control and ETags •
AFNetworking supports this by default • Rails gives you these for free
Smarter Requests • Side loading associated resources • HTTP Pipelining
for GET, HEAD, PUT, and DELETE requests • HTTP compression
Future
HTTP 2.0 • Based on SPDY • Multiplexing • Server
Push • Better compression
JSON API • Standard hypermedia type • Always namespaced •
Always returns collections for easy parsing • Support for batch operations
JSON Patch • Standard hypermedia type for updating records •
Easily handle associations • Send minimal amount of information
Thanks blog.steveklabnik.com designinghypermediaapis.com afnetworking.com jsonapi.org