CayøLargo
← Back to siteAPI ReferencePricingChangelog
v1.0Swagger ↗

Getting Started

Pagination and Bulk Data

How to fetch large time ranges efficiently using cursor-based pagination with from, to, and limit.

How pagination works

Every time-series endpoint accepts three query parameters that control the window of data returned:

fromStart of the time window (ISO 8601, UTC). Default: latest snapshot only. A from older than your tier allows is clamped, not refused.
toEnd of the time window (ISO 8601, UTC). Default: now.
limitMaximum rows returned. Default 500 on every tier. The ceiling is your tier's row cap: Core 1,000, Pro 5,000, Alpha 10,000. Asking for more is clamped down silently, so check count.

Results are sorted by timestamp descending (newest first). If count in the response equals your limit, there is likely more data. To fetch the next page, set to to the oldest timestamp in your current batch and repeat.

Walking backwards eventually reaches your tier's history floor. We do not refuse that request and we do not silently truncate it: the window is clamped to the floor and the response carries window_start with the oldest instant served, plus history_clamped: true. Stop your loop when you see it, or when count comes back below your limit. Both conditions mean the same thing, that there is nothing further back to fetch.

How much data is there?

Snapshot endpoints return one row per coin per cycle, so the row count depends on your tier's sampling resolution, not just on the range. Core reads 4-hourly cycles, Pro hourly, Alpha every stored 10-minute cycle. One coin:

Time rangeCore
6/day, cap 1,000
Pro
24/day, cap 5,000
Alpha
144/day, cap 10,000
1 day6 (1 req)24 (1 req)144 (1 req)
7 days42 (1 req)168 (1 req)1,008 (1 req)
30 days180 (1 req)720 (1 req)4,320 (1 req)
90 days540 (1 req)2,160 (1 req)12,960 (2 reqs)

Per-option endpoints are the ones that actually need pagination. On /v1/greeks/snapshot a single BTC cycle is roughly 700 rows, and the six coins together are roughly 2,500. At Alpha's 10,000-row cap that is about 14 BTC cycles, so one full-size request covers a little over two hours of one coin. Plan historical backfills in days, not in single calls.

Python: fetch 30 days of vol/surface

python
import requests
import time

API_KEY = "clg_alpha_YOUR_KEY"
BASE    = "https://api.cayolargo.fi"
COIN    = "BTC"

# 30 days of 10-min data = 4,320 rows
params = {
    "coin":  COIN,
    "from":  "2026-02-10T00:00:00Z",
    "to":    "2026-03-12T00:00:00Z",
    "limit": 10000,
}

all_rows = []

while True:
    r = requests.get(
        f"{BASE}/v1/vol/surface",
        params=params,
        headers={"X-API-Key": API_KEY},
    )
    data = r.json()
    batch = data["results"]
    all_rows.extend(batch)

    # If we got fewer rows than limit, we have everything
    if data["count"] < params["limit"]:
        break

    # We reached the history floor for this tier. Nothing older exists for us.
    if data.get("history_clamped"):
        print(f"history floor reached at {data['window_start']}")
        break

    # Move the cursor: set "to" to the oldest timestamp in this batch
    oldest = batch[-1]["timestamp"]
    params["to"] = oldest

    # Be polite
    time.sleep(0.5)

print(f"Fetched {len(all_rows)} rows")

Tips

Use max limitSet limit to the maximum for your tier (1,000 / 5,000 / 10,000). Fewer requests means faster bulk downloads.
Filter by coinThe coin parameter is required on most endpoints. If you need all 6 coins, loop over each coin separately.
Latest onlyOmit from and to entirely to get just the latest snapshot. No pagination needed.
DeduplicationWhen paginating, the boundary row (oldest in page N) may appear again as the newest in page N+1. Deduplicate by timestamp after collection.
Rate limitsDaily: Core 10,000, Pro 50,000, Alpha Unlimited (fair use). A per-minute burst limit also applies on every tier. Plan bulk downloads accordingly.
Backfill onceFetch the full history once, store locally, then poll the latest snapshot every 10 minutes going forward. Do not re-fetch the full range on every run.

See Tiers & Limits for per-tier request and row limits, and Response Format for the JSON envelope structure.