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
Chris Guzman
August 20, 2017
Technology
0
43
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
doda開発 生成AI元年宣言!自家製AIエージェントから始める生産性改革 / doda Development Declaration of the First Year of Generated AI! Productivity Reforms Starting with Home-grown AI Agents
techtekt
0
180
Azure AI Foundryでマルチエージェントワークフロー
seosoft
0
130
JSX - 歴史を振り返り、⾯⽩がって、エモくなろう
pal4de
3
1k
AWS アーキテクチャ作図入門/aws-architecture-diagram-101
ma2shita
27
9.3k
活きてなかったデータを活かしてみた話 / Shirokane Kougyou vol 19
sansan_randd
1
390
Navigation3でViewModelにデータを渡す方法
mikanichinose
0
190
vLLM meetup Tokyo
jpishikawa
1
270
成立するElixirの再束縛(再代入)可という選択
kubell_hr
0
510
評価の納得感を2段階高める「構造化フィードバック」
aloerina
1
280
TechLION vol.41~MySQLユーザ会のほうから来ました / techlion41_mysql
sakaik
0
130
CIでのgolangci-lintの実行を約90%削減した話
kazukihayase
0
330
標準技術と独自システムで作る「つらくない」SaaS アカウント管理 / Effortless SaaS Account Management with Standard Technologies & Custom Systems
yuyatakeyama
2
460
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
VelocityConf: Rendering Performance Case Studies
addyosmani
329
24k
The Pragmatic Product Professional
lauravandoore
35
6.7k
Designing for humans not robots
tammielis
253
25k
Stop Working from a Prison Cell
hatefulcrawdad
269
20k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
910
StorybookのUI Testing Handbookを読んだ
zakiyama
30
5.8k
For a Future-Friendly Web
brad_frost
179
9.8k
Producing Creativity
orderedlist
PRO
346
40k
Being A Developer After 40
akosma
90
590k
We Have a Design System, Now What?
morganepeng
52
7.6k
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