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
Building a Better API with JSON:API
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Chris Guzman
August 20, 2017
Technology
60
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Building a Better API with JSON:API
Chris Guzman
August 20, 2017
More Decks by Chris Guzman
See All by Chris Guzman
Android libraries I wish I knew when I started
chrisguzman
21
55k
Other Decks in Technology
See All in Technology
Flow 不死:AI 時代 DevOps 的不變本質
cheng_wei_chen
2
540
AIチャットの改善から見えた、良いAI体験とは / What Constitutes a Good AI Experience: Insights from Improving AI Chat
kubode
0
120
千葉での単身赴任からAWSをやり続け、千葉に戻ってきた話
yama3133
1
120
AI-DLCを “そのまま導入しなかった”話 ~組織に合わせてアジャストした 私たちの実践共有~
hiroramos4
PRO
1
440
Agile and AI Redmine Japan 2026
hiranabe
4
500
事業会社における 機械学習・推薦システム技術の活用事例と必要な能力 / ml-recsys-in-layerx-wantedly-2026
yuya4
0
160
クレデンシャル流出 ― 攻撃 3 時間 vs 復旧 10 時間。この非対称性にどう備えるか
kazzpapa3
3
590
iOS アプリの「これって不具合ですか?」を AI に調べてもらう
miichan
0
150
フルAIで個人開発して学んだあれこれ / yuruai vol.1
isaoshimizu
0
140
データレイクの「見えない問題」を可視化する
sansantech
PRO
1
220
“詰む”前に仕組みを作れ 〜技術の波に溺れないためのキャッチアップ術〜
takasyou
7
4k
Multi-Agent並列開発を 安全に回すための技術 / Technology for Safely Multi-Agent Parallel Development
tooppoo
0
210
Featured
See All Featured
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
610
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
170
How GitHub (no longer) Works
holman
316
150k
Agile that works and the tools we love
rasmusluckow
331
22k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
2
250
Amusing Abliteration
ianozsvald
1
210
Producing Creativity
orderedlist
PRO
348
40k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.3k
Design in an AI World
tapps
1
250
New Earth Scene 8
popppiees
3
2.4k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.1k
Transcript
{json:api} A specification for building APIs in JSON
{json:api} A specification for building APIs in JSON duh
None
None
{json:api}
{json:api}
{"json":"api"}
Why?
None
» Minimize requests & data between clients & servers »
Consistency, popular among consultancies » Always backwards compatible » Stable 1.0, not dead
No really
History
!+"+#$+%=
None
Spec
» data: the document’s “primary data” » errors: an array
of error objects » meta: a meta object that contains non-standard meta- information.
Data
{ "data": { "type": "articles", "id": "1", "attributes": { "title":
"Rails is Omakase" }, "relationships": { }, "links": { "self": "http://example.com/articles/1" }, } }
Relationships
{ "relationships": { "author": { "links": { "self": "/articles/1/relationships/author", "related":
"/articles/1/author" }, "data": { "type": "people", "id": "9" } } } }
Meta
{ "meta": { "count": "42", "copyright": "Copyright 2015 Example Corp.",
"authors": [ "Yehuda Katz", "Steve Klabnik", "Dan Gebhardt", "Tyler Kellen" ] } }
Errors
{ "errors": [ "id": "UUID", "status": "418", "code": "42", "title":
"You're a teapot", "detail": "The object is not short nor stout", "links": { "about": "https://httpstatuses.com/418" }, "meta": { "email": "
[email protected]
" } ] }
GET /articles Accept: application/vnd.api+json GET /articles/1 Accept: application/vnd.api+json GET /articles/1/author
Accept: application/vnd.api+json
#Request comments with an article GET /articles/1?include=comments Accept: application/vnd.api+json #Request
comments as well as the author of each of those comments GET /articles/1?include=comments.author Accept: application/vnd.api+json
GET /articles?include=comments,author &fields[people]=first-name,last-name &sort=-date » fetch all articles with their
associated comments and authors » Only be return the first and last names » Sorted by date, most recent first
POST /photos { "data": { "type": "photos", "attributes": { "title":
"Ember Hamster", "src": "http://example.com/images/productivity.png" }, "relationships": { "photographer": { "data": { "type": "people", "id": "9" } } } } }
None
None
None