Pagination
In this guide, we will look at how to work with paginated responses when querying the wunderdocs API. By default, all responses limit results to 25. However, you can go as high as 100 by adding a limit
parameter to your requests.
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. Also there are two additional attributes: totalCount
and filteredCount
. The totalCount
attribute indicates the total number of objects in the resultset, while the filteredCount
attribute indicates the number of objects returned in the response. So if you have 100 objects in your resultset and you limit the response to 25, the totalCount
will be 100 and the filteredCount
will be 25. You can use the totalCount
attribute to calculate the number of pages in your resultset. For example, if you have 100 objects and you limit the response to 25, you will have 4 pages.
Example using offset pagination
In this example we will use the offset
and limit
parameters to paginate through a list of conversations. The offset
parameter is used to indicate the number of objects to skip before returning the response. The limit
parameter is used to indicate the number of objects to return in the response.
- Name
totalCount
- Type
- integer
- Description
The total number of objects in the resultset.
- Name
filteredCount
- Type
- integer
- Description
The number of objects returned in the response.
- Name
data
- Type
- object
- Description
The actuall objects returned in the response.
Manual pagination using cURL
curl -G https://api.wunderdocs.io/v1/documents \
-H "X-API-KEY: {api-key}" \
-d limit=10 \
-d offset=2
Paginated response
{
"totalCount": 300,
"filteredCount": 10,
"data": [
{
"uid": "7d7081bb-c4a1-407e-9dd3-82fb5079e1d9",
"name": "My Template",
"creatorId": 1,
"teamId": 2,
"fields": [
{
"label": "First Name",
"key": "firstName",
"type": "text",
}
],
"created": "2023-03-22T11:42:52.000Z",
"updated": "2023-05-11T23:35:10.000Z"
},
{...},
{...}
}