mikcanf | Posts: 71

Pagination

0 votes

Hi 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="

    }


Duo_Liang | Posts: 3776

Reply to: Pagination

0 votes

Hi 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


Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off