Pagination
Tuesday, October 6, 2020 at 04:22pmHi there, when using API to pull data in using "from" / "to" parms, is the only way to control pagination via limiting data requested or do some API's have explicit pagination. Sample below is from Facebook API as an example.
],
"paging": {
"cursors": {
"after": "MTAxNTExOTQ1MjAwNzI5NDE=",
"before": "NDMyNzQyODI3OTQw"
},
"previous": "https://graph.facebook.com/me/albums?limit=25&before=NDMyNzQyODI3OTQw",
"next": "https://graph.facebook.com/me/albums?limit=25&after=MTAxNTExOTQ1MjAwNzI5NDE="
}
Reply to: Pagination
Wednesday, October 7, 2020 at 02:07pmHi Mike,
OneSpan Sign APIs don't really implemented the "Cursor-based Pagination" but a more traditional "Offset Pagination". Take package retrieval API for example:
GET /api/packages?query={status}&from={from}&to={to}&lastUpdatedStartDate={lastUpdatedStartDate}&lastUpdatedEndDate={lastUpdatedEndDate}
Response:
{
"results": [
{
"id": "mC3p1FENigGItiL3Zmojtr64e0Y=",
"status": "DRAFT",
"description": "",
"language": "en",
...
},
{...},
{...},
...
],
"count": 216
}
During a short period of time, the total count of response between "lastUpdatedStartDate" and "lastUpdatedEndDate" are fixed, so you need total of 3 calls to retrieve all 216 entities:
GET /api/packages?query={status}&lastUpdatedStartDate={lastUpdatedStartDate}&lastUpdatedEndDate={lastUpdatedEndDate}&from=1&to=99
GET /api/packages?query={status}&lastUpdatedStartDate={lastUpdatedStartDate}&lastUpdatedEndDate={lastUpdatedEndDate}&from=100&to=199
GET /api/packages?query={status}&lastUpdatedStartDate={lastUpdatedStartDate}&lastUpdatedEndDate={lastUpdatedEndDate}&from=200&to=299
Until the actual count equals to 216.
Duo