Pagination

Results from the Data Access API can produce a large amount of data. There are a number of methods available to help mitigate issues that may arise when dealing with a lot of data. With the accounts endpoint, data can be limited by requesting one account at a time.

When using the transactions endpoint, requests may be refined by using a narrower date range. Another method is to request data in batches using offset pagination. Offset pagination uses the offset parameter as a way of bookmarking where you are in pages of results.

The following parameters may be used:

startTime: the batch’s start date—oldest transactionTimestamp

endTime: the batch’s end date—newest transactionTimestamp

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

An example of offset pagination

The steps below use Mikomo’s TAuser_4.

For more on how to use sandbox & Mikomo see: Introduction to Sandbox.

Page one of results

To test pagination, make a call to the transactions endpoint with the following parameters:

startTime: 2020-01-04T00:00:00Z

endTime: 2020-05-24T00:00:00Z

offset: 0

limit: 5

The results will list the oldest transactions, numbered 0-4, in the specified date range.

Example 1st page request:

curl --location --request GET 'https://sandbox-access.ddp.akoya.com/fdx/v4/mikomo/accounts/48441630253593369/transactions?startTime=2020-01-04T00:00:00Z&endTime=2020-05-24T00:00:00Z&offset=0&limit=5' --header 'Content-Type: application/json' --header 'Authorization: Bearer <id_token>'



Postman example of a transaction call using paginationPostman example of a transaction call using pagination

Postman example of a transaction call using pagination



Example results

{
    "page": {
        "nextOffset": 5,
        "prevOffset": 0,
        "totalElements": 287
    },
    "transactions": [
        {
            "investmentTransaction": {
                "accountId": "48441630253593369",
                "amount": -28.05,
                "category": "PCRA CHANGE IN VALUE",
                "description": "PERS CHOICE RETIREMNT ACCOUNT",
                "referenceTransactionId": "20160105923JPB",
                "subCategory": "1039",
                "symbol": "PCRA",
                "transactionId": "13936209020",
                "transactionTimestamp": "2020-01-05T00:00:00Z",
                "transactionType": "OTHER",
                "unitType": "SHARES",
                "units": -28.05
...

Page information

The results of your first transaction call will return the specified number of transactions (set with limit) and provides page information:

totalElements: the number of results in the date range

prevOffset: the marker (number in list of transactions) which starts the previous page

nextOffset: the marker (number in list of transactions) which starts the next page

Page two of results

The following request can page to the next batch of responses by setting the offset value equal to the previous nextOffset. For instance, in the example above, the resulting nextOffset = 5. To page to the next batch of results use offset = 5.

startTime: 2020-01-04T00:00:00Z

endTime: 2020-05-24T00:00:00Z

offset: 5

limit: 5

Example 2nd page request:

curl --location --request GET 'https://sandbox-access.ddp.akoya.com/fdx/v4/mikomo/accounts/48441630253593369/transactions?startTime=2020-01-04T00:00:00Z&endTime=2020-05-24T00:00:00Z&offset=5&limit=5' --header 'Content-Type: application/json' --header 'Authorization: Bearer <id_token>'

Example result:

{
    "page": {
        "nextOffset": 10,
        "prevOffset": 5,
        "totalElements": 287
    },
    "transactions": [
        {
            "investmentTransaction": {
                "accountId": "48441630253593369",
                "amount": -101.48,
                "category": "PCRA CHANGE IN VALUE",
                "description": "PERS CHOICE RETIREMNT ACCOUNT",
                "referenceTransactionId": "20160106923LVG",
                "subCategory": "1039",
                "symbol": "PCRA",
                "transactionId": "13936209019",
                "transactionTimestamp": "2020-01-06T00:00:00Z",
                "transactionType": "OTHER",
                "unitType": "SHARES",
                "units": -101.48
            }
        },
...

In this example, the resulting nextOffset = 10.

Page back and forward

In your next request, to page to the next batch of results use offset = 10.

To page back to the previous batch, use offset = 5.