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
55
0
Share
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
React Compiler導入から21ヶ月、いま始めるならこうやる
astatsuya
2
260
【2026年版】プロジェクトマネジメント実践論|現役エンジニアが語る!~チームでモノづくりをする時のコツとは?~
mixi_engineers
PRO
1
110
【関西製造業祭り2026春】現場を変える技術はここまで来た〜世界最大の製造業見本市から持って帰ってきたもの〜
tanakaseiya
0
180
障害対応のRunbookは作った、でも本当に動くの? AWS FIS で EKS の AZ 障害を再現してみた
tk3fftk
0
110
Gaussian Splattingの実用化 - 映像制作への展開
gpuunite_official
0
200
アプリブロック機能のつくりかたと、AIとHTMLの不合理な相性の良さについて
kumamotone
1
260
いつの間にかデータエンジニア以外の業務も増えていたけど、意外と経験が役に立ってる
zozotech
PRO
0
670
オライリーイベント登壇資料「鉄リサイクル・産廃業界におけるAI技術実応用のカタチ」
takarasawa_
0
410
Terragrunt x Snowflake + dbt で作るマルチテナントなデータ基盤構築プラットフォーム
gak_t12
0
460
Loadbalancing exporter internals
ymotongpoo
1
110
Claude Code で使える DuckDB Skills を試してみた / DuckDB Skills and Claude Code
masahirokawahara
1
790
10サービス以上のメール到達率改善を地道に継続的に進めている話 / Continue to improve email delivery rates across multiple services
yamaguchitk333
6
2.1k
Featured
See All Featured
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
390
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Producing Creativity
orderedlist
PRO
348
40k
ラッコキーワード サービス紹介資料
rakko
1
3.3M
Unsuck your backbone
ammeep
672
58k
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
Chasing Engaging Ingredients in Design
codingconduct
0
190
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
500
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
3k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Done Done
chrislema
186
16k
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