JSON:API
Our API follows the JSON:API Specification to maintain a consistent and predictable structure in both requests and responses. By adhering to this format, we ensure each endpoint behaves in a standardized way, making it easier to parse data, handle errors, and navigate relationships between resources.
Core Implementation Details
-
Resources
- We treat each entity (e.g.,
users
,posts
,comments
) as a “resource.” - Resources in our API have:
- A type (e.g.,
"posts"
) - A unique id
- attributes (the data of the resource)
- relationships (references to other resources)
- A type (e.g.,
- We treat each entity (e.g.,
-
Relationships
- When a resource references others (for instance, a
post
has manycomments
), we include arelationships
object that describes these links. - The relationship can contain identifiers, links, and/or metadata about how the resources connect.
- When a resource references others (for instance, a
-
Compound Documents
- To avoid multiple network requests, we often provide “included” resources in the same response.
- For example, retrieving a
post
can also include its associatedcomments
orauthor
information.
-
Error Handling
- We return errors in a standardized JSON:API format, which can include fields like
status
,title
, anddetail
. - This makes client-side error handling more straightforward.
- We return errors in a standardized JSON:API format, which can include fields like
-
Filtering, Pagination & Sorting
For details on filtering, pagination, and sorting, see our dedicated guide.
- Our API uses conventional JSON:API query parameters for filtering (e.g.,
filter[author]=123
), paginating (e.g.,page[size]=25&page[number]=2
), and sorting (e.g.,sort=-created_at
).
- Our API uses conventional JSON:API query parameters for filtering (e.g.,
Example Response
Below is an example of how we might return a post
with its author included:
{
"data": [
{
"type": "posts",
"id": "1",
"attributes": {
"title": "Hello World",
"content": "This is my first post."
},
"relationships": {
"author": {
"data": { "type": "users", "id": "10" }
}
},
"links": {
"self": "https://api.example.com/posts/1"
}
}
],
"included": [
{
"type": "users",
"id": "10",
"attributes": {
"username": "JaneDoe",
"email": "jane@example.com"
},
"links": {
"self": "https://api.example.com/users/10"
}
}
]
}
-
data
holds the primary resource(s)—in this case, a list ofposts
. -
relationships
points to related resources such asauthor
. -
included
provides theuser
resource directly in the same response. -
links
likeself
direct you to the resource’s own URL.
Conclusion
Because our API is built on JSON:API principles, you can rely on uniform resource structures, predictable relationships, and consistent error responses across all endpoints. For more details or advanced features, see our specific endpoint documentation or refer to the JSON:API specification.