Pagination
In this guide, we will look at how to work with paginated responses when querying the Kalixo API. By default, all responses limit results to ten. However, you can go as high as 100 by adding a limit
parameter to your requests. If you are using one of the official Kalixo API client libraries, you don't need to worry about pagination, as it's all being taken care of behind the scenes.
When an API response returns a list of objects, no matter the amount, pagination is supported. In paginated responses, objects are nested in a data
attribute and have a has_more
attribute that indicates whether you have reached the end of the last page. You can use the starting_after
and endding_before
query parameters to browse pages.
Example Skip and Take
In this example, we demonstrate how to implement pagination using the skip and take options. By utilizing skip and take, you can control the number of items returned per page.
To paginate through the results, you can follow these guidelines:
- Name
skip
- Type
- string
- Description
Use the skip option to determine how many items to skip in the result set. For example, if you want to fetch the second page, you would skip the items from the first page. Default value for skip if not included as query param is 1.
- Name
take
- Type
- string
- Description
Use the take option to specify the number of items to retrieve per page. This helps limit the result set to the desired page size. Default value for take if not included as query param is 20.
Manual pagination using cURL
curl -X GET \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
"https://api.kalixo.io/v1/catalog/products?skip=1&take=30"
Paginated response
{
"count": 432,
"skip" : 1,
"take" : 30,
"data": [
{
"id": 1,
// ...
},
{
"id": 2
// ...
},
{
"id": 3
// ...
}
]
}