Pagination

Token-Based Pagination

The apeek API uses token-based pagination. Each response includes a pagination object that tells you how many records were returned and provides a next_url to fetch the next page.

How It Works

1. Make your initial request with the query parameters you need.
2. The response includes a pagination object.
3. If there are more results, next_url contains the full URL for the next page, including a token_id.
4. Follow next_url to get the next page. Repeat until next_url is absent or null.

Example Response

{
  "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": "100",
    "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": [ ... ]
}

Pagination Fields

  • count — Number of records returned in the current page
  • next_url — URL to fetch the next page of results. Includes all original query parameters and a token_id that the server uses to resume from where the previous page ended. When there are no more results, this field is absent.

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.get("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)}")