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
JSON API - standards please
Search
Michal Ostruszka
January 14, 2014
Programming
270
2
Share
JSON API - standards please
Slides from my Meet.JS talk on JSON API standards (JSend and JSON API specifications)
Michal Ostruszka
January 14, 2014
More Decks by Michal Ostruszka
See All by Michal Ostruszka
Building modern web applications. Single Responsibility Principle applied
mostr
2
430
Building modern web applications. Single Responsibility Principle applied
mostr
4
160
You don't need Rails
mostr
3
180
Backendless frontend development
mostr
2
320
Code review, do you speak it?
mostr
0
560
Things you probably should know about JavaScript that you may not have been told before
mostr
6
710
Other Decks in Programming
See All in Programming
ソフトウェア設計の結合バランス #phperkaigi
kajitack
0
490
Symfony AI in Action - SymfonyLive Berlin 2026
chr_hertel
1
110
書籍「ユーザーストーリーマッピング」が私のバイブル
asumikam
4
480
🦞OpenClaw works with AWS
licux
1
330
AIと共に生きる技術選定 2026
sgash708
0
120
Firefoxにコントリビューションして得られた学び
ken7253
2
150
実践ハーネスエンジニアリング:ステアリングループを実例から読み解く / Practical Harness Engineering: Understanding Steering Loops Through Real-World Examples
nrslib
2
1.4k
Cache-moi si tu peux : patterns et pièges du cache en production - Devoxx France 2026 - Conférence
slecache
0
330
Kingdom of the Machine
yui_knk
2
1.4k
Vibe NLP for Applied NLP
inesmontani
PRO
0
590
(Re)make Regexp in Ruby: Democratizing internals for the JIT
makenowjust
3
990
AWSコミュニティ活動は顧客のクラウド推進に効くのか / Do AWS community activities help customers adopt the cloud?
seike460
PRO
0
170
Featured
See All Featured
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.5k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
190
My Coaching Mixtape
mlcsv
0
120
Scaling GitHub
holman
464
140k
Side Projects
sachag
455
43k
GitHub's CSS Performance
jonrohan
1032
470k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.1k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
490
Bash Introduction
62gerente
615
210k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
320
Tell your own story through comics
letsgokoyo
1
910
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
380
Transcript
JSON API standards please Michał Ostruszka | @mostruszka | michalostruszka.pl
every app defines own “standard” Wild, wild west
{ “status”: “ok”, “response”: {...} }
{ “result”: “success”, “data”: [] }
{ “status”: 200 }
{ “result”: “error”, “msg”: “No such user” }
{ “status”: 404, “error”: “No such user” }
{ “status”: 404, “errors”: [ “No such user” ] }
and so on...
sometimes even within one app Inconsistency
Any standards?
“JSend is a specification that lays down some rules for
how JSON responses from web servers should be formatted” JSend
JSend - success { “status”: “success”, “data”: { “posts”: [...]
} } required: status, data
JSend - failure { “status”: “fail”, “data”: { “title”: “Title
is required” } } Used for invalid data responses required: status = “fail”, data
JSend - error { “status”: “error”, “message”: “Server goes bananas”
} Used for server errors required: status = “error”, message optional: code, data
simple easy to follow, “data” can contain anything That’s all
only 41 various interpretations not always flexible enough Wait, HTTP
codes?
“If you've ever argued with your team about the way
your JSON responses should be formatted, JSON API is your anti-bikeshedding weapon.” JSON API
defines data format, mime type registered application/vnd.api+json relations etc Bigger
spec
ID style URL style Flavors
JSON API - Simple { “posts”: [{ “id”: 1, “title”:
“Hello world” }] } always as list, even for 1 item item MUST contain “id”
JSON API - Relationships { “posts”: [{ “id”: 1, “title”:
“Hello world”, “links”: { “author”: “9” “comments”: [“1”,”2”,”3”] } }] } Client needs to know how to build author url
Embedded in “linked” field Save HTTP requests Compound docs
Same for simple resources URL Style
URL Style { “posts”: [{ “id”: 1, “title”: “Hello world”,
“links”: { “author”: “http://example.com/author/2” } }] } client can blindly follow URLs
GET /posts/1?include=comments GET /posts/1?include=comments.author Selective fetching
Defines how to send data POST, PUT, DELETE etc Resources
manipulation
No status in response body HTTP codes used to determine
status Relies on HTTP codes
Once JSON API is stable, it will always be backwards
compatible using a never remove, only add strategy Changes?
http://labs.omniti.com/labs/jsend http://jsonapi.org/ Where to find?
Possible adoption? Stick to standard for your project JSend looks
easier Final word
kthxbye