Pagination
In this guide, we will look at how to work with paginated responses when querying the VaporCMS API. By default, all responses limit results to ten. However, you can go as high as 100 by adding a pageSize
parameter to your requests.
When an API response returns a list of objects, no matter the amount, pagination is supported. In paginated responses, we return a pagination
object, which contains the needed information to get the next page.
Example using pagination
In this example, we'll featch the first page of our articles
resource, taking 100 items per page.
- Name
page
- Type
- number
- Description
The current page in the pagination response.
- Name
pageSize
- Type
- number
- Description
The number of items returned in the current page.
- Name
totalPages
- Type
- number
- Description
The total number of pages available for the dataset.
Pagination
curl -G https://api.vaporcms.com/v0/{blogId}/articles \
-H "Authorization: Bearer {token}" \
-d page=1 \
-d pageSize=100
Paginates Response
{
"articles": [
{
"id": "cm1uxrqxv000ife8jjwweuu87",
...
},
{
"id": "cm1uxrqxv000ife8jjwweuu17",
...
},
...
],
"totalCount": 500,
"pagination": {
"page": 1,
"pageSize": 100,
"totalPages": 5
}
}