JSON-API
JSON-API is a spec for JSON contracts between APIs and their clients. Because ember-data uses JSON-API by default, and as a guide for its internal data structures, it's useful to be familiar with it when working with ember-data.
If you’ve ever argued with your team about the way your JSON responses should be formatted, JSON API can be your anti-bikeshedding tool.
By following shared conventions, you can increase productivity, take advantage of generalized tooling, and focus on what matters: your application.
Clients built around JSON API are able to take advantage of its features around efficiently caching responses, sometimes eliminating network requests entirely.
-
JSON-APIBasic Objects, Errors and Metadata
We'll work through some examples of how basic objects are defined, according to the JSON-API standard.
-
JSON-APIRelationships & Compound Documents
In JSON-API, we can define relationships in multiple ways:
- Including related records directly in the JSON
- Providing explicit references for each related record (i.e., a type and id)
- Providing a URL for retrieving related records at a later time
We'll look at examples for each, and discuss use of the
include
queryParam for requesting inclusion of related records.