All list endpoints return a paginated wrapper object with the following fields:

  • data: An array of the underlying object returned by the list operation.
  • next_cursor: A cursor value that can be used to fetch the next page of results.

Each list endpoint may also support a combination of filter parameters. The same filter parameters should be used on subsequent pagination requests to fetch the next page of results.

The page size has a maximum and default value of 100 items. This page size can be overridden by passing the limit parameter to the list endpoint.

Example

This example demonstrates fetching the accounts via pagination until all accounts have been fetched.


import requests

api_url = "https://api.useswift.dev"
headers = {
    "Authorization": "Bearer YOUR_API_KEY"
}

# Get first page of accounts
response = requests.get(
    f"{api_url}/accounts",
    headers=headers,
    params={"limit": 25}
)
accounts_page = response.json()

# Print first page of accounts
for account in accounts_page["data"]:
    print(f"Account: {account['id']}")

# Get next page using cursor
while accounts_page.get("next_cursor"):
    response = requests.get(
        f"{api_url}/accounts",
        headers=headers,
        params={
            "limit": 25,
            "cursor": accounts_page["next_cursor"]
        }
    )
    accounts_page = response.json()

    # Print next page of accounts
    for account in accounts_page["data"]:
        print(f"Account: {account['id']}")