JSON:API Specification
Reference for the JSON:API specification for consistent REST API responses with relationships and links.
Document Structure
JSON:API documents have a top-level data, errors, or meta member. Resource objects contain id, type, attributes, and relationships. Relationships link to other resources by id and type, avoiding embedded data by default. Links provide URLs for pagination and related resources. The included section sideloads related resources to avoid N+1 requests. The format standardizes error objects with status, code, title, and detail.
- resource object
- id, type, attributes
- relationships
- Links to other resources
- included
- Sideloaded resources
standardized shape by id + type avoid N+1 Conventions
Relationships can be to-one or to-many, with links for fetching or manipulating. Sparse fieldsets allow requesting only specific fields via query params. Sorting, filtering, and pagination use standardized query parameters. PATCH updates use JSON Patch-like merge semantics. The specification reduces API design decisions and client complexity. Content type must be application/vnd.api+json.
- sparse fieldsets
- Request specific fields
- pagination
- Standardized query params
- content type
- application/vnd.api+json
fields[type]=field1,field2 page[number], page[size] media type required