Pagination
Token-Based Pagination
When a query returns more records than fit in a single page, the API splits the result across multiple pages.
Each response includes a pagination object with the current page count
and a next_url to fetch the next page.
How it works
- Make your initial request with the required query parameters.
- Check the
paginationobject in the response. - If
next_urlis present, it contains a relative URL with all original parameters plus an encryptedtoken_id. - Prepend the base URL (
https://api.apeek.io/api/v1) tonext_urland make a GET request. - Repeat until
next_urlisnull, which means all records have been returned.
Pagination fields
| Field | Type | Description |
|---|---|---|
count |
string | Number of records returned in the current page |
next_url |
string | null | Relative URL for the next page (includes all original query parameters and an encrypted token_id). null when there are no more results. |
Example response with pagination
{
"status": "OK",
"message": "Data retrieved successfully",
"meta": {
"schema_version": "1.0",
"frequency": "Weekly",
"fields": {
"date": "string (YYYY-MM-DD)",
"series": "string",
"value": "numerical string"
}
},
"pagination": {
"count": "10000",
"next_url": "/economic-data/ui_weekly_claims?series=initial_claims_sa,continued_claims_sa&date_from=2025-01-01&date_to=2026-01-01&token_id=7c1b453e164b..."
},
"data": [ ... ]
}
Last page (no more results)
When the final page is reached, next_url is null:
"pagination": {
"count": "347",
"next_url": null
}
Fetching all pages (Python)
import requests
BASE_URL = "https://api.apeek.io/api/v1"
params = {
"series": "initial_claims_sa,continued_claims_sa",
"date_from": "2025-01-01",
"date_to": "2026-01-01",
"api_key": "your_api_key_here"
}
all_records = []
response = requests.get(
f"{BASE_URL}/economic-data/ui_weekly_claims",
params=params
)
result = response.json()
all_records.extend(result["data"])
while result["pagination"].get("next_url"):
response = requests.get(
f"{BASE_URL}{result['pagination']['next_url']}"
)
result = response.json()
all_records.extend(result["data"])
print(f"Total records fetched: {len(all_records)}")
Important notes
- Do not construct or modify
token_idvalues yourself. Always use thenext_urlreturned by the API. - Each
next_urlalready contains all the original query parameters. You only need to prepend the base URL. - Pagination tokens are encrypted and tied to your original query. Using a token from a different query will result in an error.