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
0
47
Building a Better API with JSON:API
Chris Guzman
August 20, 2017
Tweet
Share
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
BPaaSオペレーション・kubell社内 n8n活用による効率化検証事例紹介
kentarofujii
0
310
SMTP完全に理解した ✉️
yamatai1212
0
110
KubeCon + CloudNativeCon NA ‘25 Recap, Extensibility: Gateway API / NRI
ladicle
0
160
Zephyr RTOS の発表をOpen Source Summit Japan 2025で行った件
iotengineer22
0
280
Exadata Database Service ソフトウェアのアップデートとアップグレードの概要
oracle4engineer
PRO
1
1.2k
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.3k
エンジニアとして長く走るために気づいた2つのこと_大賀愛一郎
nanaism
1
260
入社1ヶ月でデータパイプライン講座を作った話
waiwai2111
1
130
AI時代にあわせたQA組織戦略
masamiyajiri
6
2.9k
あたらしい上流工程の形。 0日導入からはじめるAI駆動PM
kumaiu
2
320
AI推進者の視点で見る、Bill OneのAI活用の今
sansantech
PRO
1
240
ReproでのicebergのStreaming Writeの検証と実運用にむけた取り組み
joker1007
0
510
Featured
See All Featured
What does AI have to do with Human Rights?
axbom
PRO
0
1.9k
GitHub's CSS Performance
jonrohan
1032
470k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
200
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.3k
Speed Design
sergeychernyshev
33
1.5k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
34k
Test your architecture with Archunit
thirion
1
2.1k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
59
42k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
190
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