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
500
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
132
6.3k
Elixir and Ecto
vanstee
5
730
Bootstrap
vanstee
8
670
Consensus: An Introduction to Raft
vanstee
22
2.6k
Convergent Replicated Data Types
vanstee
4
600
Pour Over Brewing Method
vanstee
1
240
Celluloid & DCell
vanstee
4
410
Map Reduce & Ruby
vanstee
10
620
Other Decks in Programming
See All in Programming
SIMD Parallel Programming with the Vector API
josepaumard
0
170
効率化に挑戦してみたらモバイル開発が少し快適になった話
ryunakayama
0
130
スキーマ駆動開発による品質とスピードの両立 - 私達は何故、スキーマを書くのか
kentaroutakeda
0
170
冗長なエラーログを削減し、スタックトレースを手に入れる / Reducing Verbose Error Logs and Obtaining Stack Traces
upamune
0
550
AWS Application Composerで始める、 サーバーレスなデータ基盤構築 / 20240406-jawsug-hokuriku-shinkansen
kasacchiful
1
260
今、知っておきたい! 生成AIエージェントの世界
elith
3
360
Rethinking UI building strategies @ SFI 2024
letelete
0
270
AWS CDKコントリビュートTIPS / aws-cdk-contribution-tips
gotok365
2
160
ゆるい個人開発のススメ
kuroppe1819
10
990
CA.swift19 恋するAIアプリ開発の裏側
oskmr
0
360
Elm 0.19.0 Changes
bkuhlmann
0
490
What We Can Learn From OSS
inouehi
0
420
Featured
See All Featured
The Power of CSS Pseudo Elements
geoffreycrofte
60
5k
Build your cross-platform service in a week with App Engine
jlugia
225
17k
Reflections from 52 weeks, 52 projects
jeffersonlam
345
19k
Why Our Code Smells
bkeepers
PRO
331
56k
GraphQLとの向き合い方2022年版
quramy
32
12k
The Cost Of JavaScript in 2023
addyosmani
16
3.9k
Creatively Recalculating Your Daily Design Routine
revolveconf
210
11k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
14
1.5k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
2
3.4k
Web Components: a chance to create the future
zenorocha
305
41k
A better future with KSS
kneath
231
16k
Making Projects Easy
brettharned
108
5.5k
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