Responses
Every successful API response is JSON. The shape is consistent across all endpoints, with one addition for list endpoints and a small extra field for some actions.
Single Resource
Most endpoints return a single object wrapped in data:
{
"data": {
"version": "0.2.28"
}
}
The client reads data and ignores everything else. There are no other top-level fields on a plain success response.
List Endpoints
List endpoints return an array in data plus a pagination object:
{
"data": [ ... ],
"pagination": {
"page": 1,
"limit": 25,
"total": 142,
"total_pages": 6
}
}
The pagination object describes the current page. See Pagination for parameters and iteration.
Actions
Some action endpoints add a changed field and, when nothing changed, a message:
{
"data": { ... },
"changed": true
}
{
"data": { ... },
"changed": false,
"message": "Website is already enabled."
}
changed is true when the server actually modified something. It is false when the request was valid but the resource was already in the desired state.
This pattern appears on endpoints that toggle or set a value to a known state, where re-running the same request should be safe and idempotent.
The message is human-readable and may be translated. Do not parse it. Rely on changed for logic.
Errors
Errors use a different shape:
{
"error": {
"code": "not_found",
"message": "Website not found"
}
}
See Errors for the full list of codes.
Content Type
All responses are application/json, with one exception: the API never returns HTML or other formats. Even 404 on an unknown route returns JSON.
Related
- Pagination - page parameters and list iteration
- Errors - error codes and error response format
- Endpoints - endpoint reference