Contact Us

Overview

By default, ModernFi uses a cursor based pagination mechanism for all List endpoints. This allows the API user to request paged data in a manner that makes sense for the given application.

To interact with paginated endpoints, the limit query parameter must be included in the API request otherwise the API will return a 400. This parameter defines the maximum number of resources that will be returned by the API. In the API response, there will be a next_page_token that tells the API user whether there are more resources available for the given query. If the next_page_token is empty, then there are no more resources to fetch, and another API request does not need to be sent.

Example

Let's take the list Accounts paginated endpoint as an example.

In the request, we define a limit of 1 and omit the next_page_token:

curl --request GET \
     --url 'https://api.sandbox.modernfi.com/depositors/654bcddcc56b455a52ef4ff8/accounts?limit=1' \
     --header 'accept: application/json' \
     --header 'authorization: Bearer {{insert token here}}'
{
  "data": {
    "depositor_accounts": [
      {
        "id": "654bcddcc56b455a52ef4ff8",
        "name": "Depositor Checking Account",
        "pending_balance": 0,
        "posted_balance": 0
      }
    ]
  },
  "next_page_token": "654bcddcc56b455a52ef4ff8"
}

In the response, we can see that next_page_token is non-empty, meaning there are still results for the original query. To fetch the next page of data, we include next_page_token in the query.

curl --request GET \
     --url 'https://api.sandbox.modernfi.com/depositors/654bcddcc56b455a52ef4ff8/accounts?limit=1&next_page_token=654bcddcc56b455a52ef4ff8' \
     --header 'accept: application/json' \
     --header 'authorization: Bearer {{insert token here}}'
{
  "data": {
    "depositor_accounts": [
      {
        "id": "654bcddcc56b455a52ef4ff9",
        "name": "Depositor Checking Account",
        "pending_balance": 0,
        "posted_balance": 0
      }
    ]
  },
  "next_page_token": "654bcddcc56b455a52ef4ff9"
}

When the cursor has been fully exhausted, the API will return an empty next_page_token.

ℹ️

Note

You may receive an empty response in addition to the empty next_page_token.

For example, let's exhaust this cursor:

curl --request GET \
     --url 'https://api.sandbox.modernfi.com/depositors/654bcddcc56b455a52ef4ff8/accounts?limit=1&next_page_token=654bcddcc56b455a52ef4ff9' \
     --header 'accept: application/json' \
     --header 'authorization: Bearer {{insert token here}}'
{
  "data": {
    "depositor_accounts": []
  },
  "next_page_token": ""
}

Here we can see that the cursor has been fully exhausted: there are no more depositor_account resources and the next_page_token is empty.

For questions or further details on pagination, please contact the ModernFi team.