SlideShare a Scribd company logo
JSON API Specification
Wojciech Langiewicz, https://www.wlangiewicz.com
1
JSON API
● Specification published in 2015:
http://www.cerebris.com/blog/2015/06/04/jsonapi-1-0/
● http://jsonapi.org/format/
● No large company behind it
2
What is JSON API?
Document describing multiple aspects of
how RESTful API should behave
3
What’s Covered By Specification?
● URL Structure
● How request should look like
● How response will look like
● How to perform server-side includes (fetching multiple related resources)
● How to publish and update documents
● How to handle errors
4
JSON API And Hypermedia
● HATEOAS - Hypermedia as the Engine of Application State
● Server can provide dynamic links
● Each of the links can have a meaning attached
● No need to hardcode URLs on the client side
● Clients can adapt to:
○ Contents of the response
○ Links returned which might allow them to traverse relationships
5
Motivation For Using JSON API Spec
● Anti-bikeshedding
● Formal specification and validation
● API-first approach
6
Bikeshedding
Technical disputes over minor, marginal issues conducted while more serious
ones are being overlooked. The implied image is of people arguing over what
color to paint the bicycle shed while the house is not finished.
Source: http://www.urbandictionary.com/define.php?term=bikeshedding
7
Formal Specification And Validation
● Documentation always up to date
● JSON Schema
● Validations
8
API-first Approach
● Design your API before implementing
● Prepare examples of requests and responses
● Validate examples against API Schema
● Replace examples with real implementations
9
Demo Time
10
Tooling
● Libraries
● JSON Schema
11
JSON API Libraries: Example Scala Library
● https://github.com/zalando/scala-jsonapi
● JSON API spec with Spray, Play! or Circe
● Example:
https://github.com/zalando/scala-jsonapi/blob/master/src/test/scala/org
/zalando/jsonapi/json/ExampleSpec.scala
12
case class Author(id: UUID, name: String, dateOfBirth: DateTime, dateOfDeath: Option[DateTime], createdAt:
DateTime, updatedAt: DateTime)
def toJsonapi(author: Author) = {
ResourceObject(
`type` = author.`type`,
id = Some(author.id),
attributes = authorAttributes(author),
relationships = authorRelationships(author),
links = List(Links.Self(selfLink(author))
)
}
def authorAttributes(author: Autor): Map[String, String] = { … }
def authorRelationships(author: Author): Map[String, Relationship] = { … }
def selfLink(author: Author): Link = Link(“/v1/author/${author.id}”)
13
JSON Schema
● A formal description of the JSON document
● Imposes restrictions about contents of the document and it’s structure
● Example (UUID):
"id": {
"type": "string",
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
}
14
JSON API Problems
● Generic API
● Weird Workarounds
○ Actions
○ Image Upload
● Slower Pace of development
15
Generic API
● API serves many different clients OK (just OK)
● Not able to add specific operations for specific clients
● Some clients need to perform workarounds or unnecessary requests
● But at the same time our API doesn’t get skewed towards specific clients
16
Weird Workarounds: No Actions
● JSON API requires you to abandon “Actions”
● But you might need to compensate for it by working around the model
17
Weird Workarounds: Image Upload
● Standard thing expected by a lot of clients
● No support for it because of media type limitations
● Workarounds:
○ Base64 encode images and send them as JSON attributes
○ Use API server only as way to get “Image Id” - client will upload image somewhere else
○ …
18
Comparing JSON API To Alternatives
● GraphQL
● Swagger / Open API
● RAML
19
JSON API vs GraphQL
● http://graphql.org/learn/
● Alternative to JSON API
● Different approach to querying and results
● Query describes the structure of the document you are requesting
● Server side includes work by creating recursive tree structure
20
Swagger / Open API/ RAML
● Complement JSON API by having structure around documentation
● My suggested approach is to:
○ Design your API according to (JSON API) specification with JSON Schema
○ Use Swagger or RAML at the same time to give your API documentation a structure
○ Generate pretty HTML documentation out of RAML or use automatic Swagger tool to do
this
21
Where To Use JSON API?
● Larger projects with long lifespan
● Multiple clients with different use cases
22
Not So Good Use Cases
● Small projects or with short lifespan
● Internal APIs
● APIs dedicated to single client
23
Summary
● Implementing JSON API requires more work
● “Thinking in resources, not actions”
● Good specification in cases of larger projects
● For smaller projects consider RAML/Swagger
24
Thank you!
Wojciech Langiewicz, https://www.wlangiewicz.com
25

More Related Content

PDF
Modern APIs with GraphQL
PPTX
What is GraphQL?
PDF
Introduction to GraphQL
PDF
Introduction to GraphQL
PPTX
Hack angular wildly
PPTX
Part One: Building Web Apps with the MERN Stack
PPTX
The API Journey: from REST to GraphQL
PPTX
GraphQL Introduction
Modern APIs with GraphQL
What is GraphQL?
Introduction to GraphQL
Introduction to GraphQL
Hack angular wildly
Part One: Building Web Apps with the MERN Stack
The API Journey: from REST to GraphQL
GraphQL Introduction

What's hot (20)

PPTX
The API Journey: GraphQL Specification and Implementation
PPTX
Angular universal
PDF
GraphQL & Relay
PDF
Metadata and Access Control
PDF
From rest api to graph ql a 10 year journey
PDF
Apache Any23 - Anything to Triples
PPTX
Comparison with storing data using NoSQL(CouchDB) and a relational database.
PPTX
The Saga of JavaScript and TypeScript: Part 1
PDF
GraphQL IndyJS April 2016
PDF
GraphQL With Relay Part Deux
KEY
MongoDB Hadoop DC
PPTX
DevNexus 2019: GraphQL From Beginner to Expert in 60 Minutes
KEY
BarCamp cloudsearch
PPTX
Getting Started with MongoDB using Node.js
PPT
Introduction to Grails
PPTX
Kotlin db migration tool
PPT
Tikal Fuse Day Access Layer Implementation (C#) Based On Mongo Db
PDF
Linked Data voor developers - PiLOD congres 25 juni
PPTX
Taking Control of your Data with GraphQL
PDF
Post-relational databases: What's wrong with web development? v3
The API Journey: GraphQL Specification and Implementation
Angular universal
GraphQL & Relay
Metadata and Access Control
From rest api to graph ql a 10 year journey
Apache Any23 - Anything to Triples
Comparison with storing data using NoSQL(CouchDB) and a relational database.
The Saga of JavaScript and TypeScript: Part 1
GraphQL IndyJS April 2016
GraphQL With Relay Part Deux
MongoDB Hadoop DC
DevNexus 2019: GraphQL From Beginner to Expert in 60 Minutes
BarCamp cloudsearch
Getting Started with MongoDB using Node.js
Introduction to Grails
Kotlin db migration tool
Tikal Fuse Day Access Layer Implementation (C#) Based On Mongo Db
Linked Data voor developers - PiLOD congres 25 juni
Taking Control of your Data with GraphQL
Post-relational databases: What's wrong with web development? v3
Ad

Similar to JSON API Specificiation (20)

PDF
APIDays 2018 - API Development Lifecycle - The secret ingredient behind RESTf...
PDF
Generating docs from APIs
PDF
Enforcing API Design Rules for High Quality Code Generation
ODP
Swagger demo
PDF
Sliding away from Roy Fielding's REST model (Filippos Vasilakis)
PDF
Apidays Paris 2023 - API design first: A case for a better language, Emmanu...
PDF
JSON API Standards
PPTX
Scaling with swagger
PDF
Always up to date, testable and maintainable documentation with OpenAPI
PPTX
SVQdotNET: Building APIs with OpenApi
PDF
INTERFACE, by apidays - Building an Accessible API Spec
PDF
OpenAPI development with Python
PDF
Testing swagger contracts without contract based testing
PPTX
Birds Eye View on API Development - v1.0
PDF
PiterPy 2016: Parallelization, Aggregation and Validation of API in Python
PDF
The Glory of Rest
PDF
Exploring an API with Blocks
PDF
apidays LIVE LONDON - Exploring an API with Blocks by Larry Kluger
PDF
Api Penetration Testing and web app pentesting
APIDays 2018 - API Development Lifecycle - The secret ingredient behind RESTf...
Generating docs from APIs
Enforcing API Design Rules for High Quality Code Generation
Swagger demo
Sliding away from Roy Fielding's REST model (Filippos Vasilakis)
Apidays Paris 2023 - API design first: A case for a better language, Emmanu...
JSON API Standards
Scaling with swagger
Always up to date, testable and maintainable documentation with OpenAPI
SVQdotNET: Building APIs with OpenApi
INTERFACE, by apidays - Building an Accessible API Spec
OpenAPI development with Python
Testing swagger contracts without contract based testing
Birds Eye View on API Development - v1.0
PiterPy 2016: Parallelization, Aggregation and Validation of API in Python
The Glory of Rest
Exploring an API with Blocks
apidays LIVE LONDON - Exploring an API with Blocks by Larry Kluger
Api Penetration Testing and web app pentesting
Ad

More from Wojciech Langiewicz (9)

PDF
Bitcoin: introduction for programmers - Pecha Kucha
PDF
Ionic 2 intro
PDF
Mutation testing in Java
PDF
Bitcoin for programmers - part 1 version 2
PDF
Introduction to Bitcoin for programmers
PDF
2014 hadoop wrocław jug
PDF
Badanie skalowalności HBase
PDF
Introduction to Octopress at DRUG
PDF
Hadoop w NK.pl
Bitcoin: introduction for programmers - Pecha Kucha
Ionic 2 intro
Mutation testing in Java
Bitcoin for programmers - part 1 version 2
Introduction to Bitcoin for programmers
2014 hadoop wrocław jug
Badanie skalowalności HBase
Introduction to Octopress at DRUG
Hadoop w NK.pl

Recently uploaded (20)

PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
top salesforce developer skills in 2025.pdf
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Understanding Forklifts - TECH EHS Solution
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
ai tools demonstartion for schools and inter college
PPTX
L1 - Introduction to python Backend.pptx
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Digital Strategies for Manufacturing Companies
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Transform Your Business with a Software ERP System
PDF
AI in Product Development-omnex systems
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
top salesforce developer skills in 2025.pdf
Odoo Companies in India – Driving Business Transformation.pdf
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Odoo POS Development Services by CandidRoot Solutions
Understanding Forklifts - TECH EHS Solution
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
ai tools demonstartion for schools and inter college
L1 - Introduction to python Backend.pptx
Upgrade and Innovation Strategies for SAP ERP Customers
wealthsignaloriginal-com-DS-text-... (1).pdf
Operating system designcfffgfgggggggvggggggggg
VVF-Customer-Presentation2025-Ver1.9.pptx
Digital Strategies for Manufacturing Companies
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Transform Your Business with a Software ERP System
AI in Product Development-omnex systems

JSON API Specificiation

  • 1. JSON API Specification Wojciech Langiewicz, https://www.wlangiewicz.com 1
  • 2. JSON API ● Specification published in 2015: http://www.cerebris.com/blog/2015/06/04/jsonapi-1-0/ ● http://jsonapi.org/format/ ● No large company behind it 2
  • 3. What is JSON API? Document describing multiple aspects of how RESTful API should behave 3
  • 4. What’s Covered By Specification? ● URL Structure ● How request should look like ● How response will look like ● How to perform server-side includes (fetching multiple related resources) ● How to publish and update documents ● How to handle errors 4
  • 5. JSON API And Hypermedia ● HATEOAS - Hypermedia as the Engine of Application State ● Server can provide dynamic links ● Each of the links can have a meaning attached ● No need to hardcode URLs on the client side ● Clients can adapt to: ○ Contents of the response ○ Links returned which might allow them to traverse relationships 5
  • 6. Motivation For Using JSON API Spec ● Anti-bikeshedding ● Formal specification and validation ● API-first approach 6
  • 7. Bikeshedding Technical disputes over minor, marginal issues conducted while more serious ones are being overlooked. The implied image is of people arguing over what color to paint the bicycle shed while the house is not finished. Source: http://www.urbandictionary.com/define.php?term=bikeshedding 7
  • 8. Formal Specification And Validation ● Documentation always up to date ● JSON Schema ● Validations 8
  • 9. API-first Approach ● Design your API before implementing ● Prepare examples of requests and responses ● Validate examples against API Schema ● Replace examples with real implementations 9
  • 12. JSON API Libraries: Example Scala Library ● https://github.com/zalando/scala-jsonapi ● JSON API spec with Spray, Play! or Circe ● Example: https://github.com/zalando/scala-jsonapi/blob/master/src/test/scala/org /zalando/jsonapi/json/ExampleSpec.scala 12
  • 13. case class Author(id: UUID, name: String, dateOfBirth: DateTime, dateOfDeath: Option[DateTime], createdAt: DateTime, updatedAt: DateTime) def toJsonapi(author: Author) = { ResourceObject( `type` = author.`type`, id = Some(author.id), attributes = authorAttributes(author), relationships = authorRelationships(author), links = List(Links.Self(selfLink(author)) ) } def authorAttributes(author: Autor): Map[String, String] = { … } def authorRelationships(author: Author): Map[String, Relationship] = { … } def selfLink(author: Author): Link = Link(“/v1/author/${author.id}”) 13
  • 14. JSON Schema ● A formal description of the JSON document ● Imposes restrictions about contents of the document and it’s structure ● Example (UUID): "id": { "type": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" } 14
  • 15. JSON API Problems ● Generic API ● Weird Workarounds ○ Actions ○ Image Upload ● Slower Pace of development 15
  • 16. Generic API ● API serves many different clients OK (just OK) ● Not able to add specific operations for specific clients ● Some clients need to perform workarounds or unnecessary requests ● But at the same time our API doesn’t get skewed towards specific clients 16
  • 17. Weird Workarounds: No Actions ● JSON API requires you to abandon “Actions” ● But you might need to compensate for it by working around the model 17
  • 18. Weird Workarounds: Image Upload ● Standard thing expected by a lot of clients ● No support for it because of media type limitations ● Workarounds: ○ Base64 encode images and send them as JSON attributes ○ Use API server only as way to get “Image Id” - client will upload image somewhere else ○ … 18
  • 19. Comparing JSON API To Alternatives ● GraphQL ● Swagger / Open API ● RAML 19
  • 20. JSON API vs GraphQL ● http://graphql.org/learn/ ● Alternative to JSON API ● Different approach to querying and results ● Query describes the structure of the document you are requesting ● Server side includes work by creating recursive tree structure 20
  • 21. Swagger / Open API/ RAML ● Complement JSON API by having structure around documentation ● My suggested approach is to: ○ Design your API according to (JSON API) specification with JSON Schema ○ Use Swagger or RAML at the same time to give your API documentation a structure ○ Generate pretty HTML documentation out of RAML or use automatic Swagger tool to do this 21
  • 22. Where To Use JSON API? ● Larger projects with long lifespan ● Multiple clients with different use cases 22
  • 23. Not So Good Use Cases ● Small projects or with short lifespan ● Internal APIs ● APIs dedicated to single client 23
  • 24. Summary ● Implementing JSON API requires more work ● “Thinking in resources, not actions” ● Good specification in cases of larger projects ● For smaller projects consider RAML/Swagger 24
  • 25. Thank you! Wojciech Langiewicz, https://www.wlangiewicz.com 25