Skip to main content

API Pagination

The Amberdata API uses cursor pagination to handle large datasets efficiently. The API automatically generates the URL for the next page of results when applicable.

Pagination Response Structure

For a 200 - OK HTTP response, the URL for the next page is found under the payload.metadata.next property:
If the full payload returns in the first request, the next response will be null.

Accessing Next Pages

To access the next page of results:
  1. Retrieve the URL from payload.metadata.next
  2. Copy your request headers from your initial API call (e.g., x-api-key, etc.)
  3. Make a HTTP GET request with the next page URL and the copied headers

Page Parameter

Some endpoints contain column names in the metadata instead of a next field. For these endpoints, use the page parameter to loop through all pages of data, beginning at page 0. Query parameter: page Options: 0 - ∞

Querying Long Timeframes

API endpoints have a maximum supported range for the query parameters endDate and startDate.
Note: Amberdata reserves the right to increase the supported range for endDate and startDate for any endpoint. An increase in the supported range is fully backwards compatible.

Example: Getting 1 Year of Data

The following example demonstrates how to get 1 year of data for the DEX - Trades endpoint, which has a maximum range of 30 days.
Warning: The code below has been verified and tested for demonstration purposes only.

Main Script (rest_endpoints.py)

Endpoint Timerange Handler (endpoint_timerange_handler.py)

This approach allows you to efficiently retrieve data for timeframes longer than the maximum supported range by automatically chunking requests and handling pagination across multiple time periods.