The API responses from v1 all extend this basic response schema. The schema is defined in Typescript.
interfaceBase_ApiV1 { _self:Link; // This is the Link of the current endpoint _version:"v1"; // The Api version _description:string; // A short desciption of what the endpoint does _links:Array<Link>; // Hyperlinks to navigate to from here}
The base response is implemented by all endpoints. It serves to make the API self descriptive.
All endpoints provide hyperlinks to help navigate the API and will list the available HTTP Request methods that are supported.
interfaceLink { href:string; methods:Array<Methods>}enumMethods { GET ="GET", POST ="POST", DELETE ="DELETE", PUT ="PUT",}
Errors
The API will return errors using this generic interface. If the response status is not 200, then you can expect to find an error message in the response.
interfaceErrorResponseextendsBase_ApiV1 { error:Error;}interfaceError { message:string; // The error message status:number; // The returned error code timestamp:string; // The timestamp, it is always UTC time}
Pagination
Endpoints that return multiple results implement a Pagination interface that will let you query for lists paginated. You can identify these endpoints as they don't support [slug] parameter, which is used for fetching data individually and we will discuss it later.
The endpoints that support pagination will return these parameters:
interfacePaginationResponse_ApiV1 { current_page:number; // The current page returned total_pages:number; // The total pages available for the current page size! page_size:number; // Defaults to 10. This is used together with current_page and total_pages to determine page content sort_by:string; // The column that is currently sorted in this response sort_direction:string; // The ordering of the sorted column. Values can be "ASC" or "DESC" sortable_columns:Array<string>; // This returns the list of valid column names that can be sorted}
When using Pagination, the request url can contain the following query parameters:
interfacePaginationSearchParams_ApiV1{ current_page:number|undefined; // The current page we are requesting, defaults to 1 if undefined page_size:number|undefined; // The size of the pages, used to override the default value : 10 sort_by:string|undefined; // The column name to sort by, defaults to "created_at" when undefined sort_direction:string|undefined; // The ordering for the sorted column. Values can be "ASC" or "DESC" defaults to "DESC" if undefined"}
If any of these are missing from the request, the default parameters are used.
A paginated GET request would have the following URL parameters: