Pagination and Sorting
Our API adheres to the JSON:API specification, providing a consistent approach to both pagination and sorting across endpoints.
Pagination
To paginate your API requests, include a page
object with the following parameters:
- page[number]: The page number you wish to retrieve.
- page[size]: The number of items per page. This value must be between 1 and 1000.
Example Request:
GET /api/articles?page[number]=2&page[size]=50
This request returns the second page of articles with 50 items per page.
Sorting
We support a straightforward sorting mechanism via the sort
parameter. Simply pass a comma-separated list of column names to sort by. To sort a column in descending order, prefix its name with a minus (-
) sign. Columns without a prefix will be sorted in ascending order.
Example Request:
GET /api/articles?sort=-created_at,title
In this example:
-
-created_at
sorts the articles by their creation date in descending order. -
title
sorts the articles by their title in ascending order.
By combining these parameters, you can efficiently tailor your API queries to suit your data retrieval needs.