Pagination
When dealing with large sets of data, retrieving results in segments can help apps process information in a more structured way. Retrieving data one page at a time is called pagination.
Consider the following when implementing link-based pagination.
1️⃣ First Request
When making an initial transaction call, use the following parameters in the request. The result of that first request returns links to use for paging.
Parameters
These parameters should only be used in constructing the first transaction call. After the first call, you must request pages with links provided in the results.
offset - The number of items to skip before the first in the response
limit - The maximum number of items to be returned in the response
startTime - ISO 8601 date format in UTC time zone. Example: 2020-03-30T04:00:00Z
endTime - ISO 8601 date format in UTC time zone. Example: 2021-03-30T04:00:00Z
Request
Example
The following example uses the sandbox and the following parameter values in the original transactions request:
providerId = mikomo
accountId = g833202fb0866d0ad83472c429
limit = 5
startTime = 2019-02-26T00:00:00Z
endTime = 2021-02-26T00:00:00Z
BASH
Response
Example Response with Paging
The value of links.next.href may contain the offset, limit, start time, and end time parameters. You should not change these values and use the link as provided.
JSON
Example Without Pagination
If an API can return all data without paging, the links.next.href values will be empty. There is no additional data to page through. Example with sandbox user mikomo_01_10, accountId = "5426873"
JSON
2️⃣ Second Request
Use the links.next.href value in the first response payload to construct the next call.
Do not change the link. Changes to offset, startTime, endTime, or limit in the provided link may cause errors or missing data.
For example, the first response returned links.next.href as:
JSON
Next Page Request
To request the next page, use the links.next.href value in the GET request:
BASH
Previous Page Request
Most pagination responses includes links.prev.href. You can use it to page back to previous results. However, a small number of providers do not support prev. If a provider does not support prev and your app requires it, store the next links as the user pages.
3️⃣ Ongoing Requests
Continue to make requests using the provided links until next is no longer present in the returned response.