How to use pagination¶
Some endpoints returning a big data sets offer a feature of data pagination, that means data are split into smaller pages in the response.
Offset-Limit pagination¶
Pagination request is specified by query part of the url:
?offset=20&limit=10
offset
- Offset position in the dataset.limit
- Number of requested items in the response.
For the specified request we would get following response:
{
"offset": 20,
"limit": 10,
"totalCount": 50,
"data": [...]
}
offset
cursor and limit
size until offset
+ limit
is equal to or greater than totalCount
and we reach the end of the data set.
Cursor pagination¶
Pagination request is specified inside of body:
{
"cursor": "0c647908-e18d-47f4-8385-9b39d6b9ecae#$IT_000_k60ivd7t - wind-small.dfsu",
"limit": 10
}
cursor
- Identifier of the last item from the previous page request. Omit if it is a request for the first page.limit
- Number of requested items in the response.
For the specified request we would get following response:
{
"cursor": "5c08b690-c973-4039-b288-40c2804da34f#$IT_000_k60ivdqw - updated dataset",
"data": [...]
}
cursor
- Identifier of the last item in the response.
This way we can iterate data pages until the cursor
is empty and we reach the end of the data set.
Note:
Current max page limit is set to 10000 items and default page limit is set to 100 items.
If the limit
property is higher than max page limit, the server will return fewer elements than expected. The response of the offset-limit request will contain the real limit.