Kwery uses cursor-based pagination. When a result set contains more data than fits in a single response, the API returns a next_cursor value you can use to fetch the next page.

How It Works

  1. Make your initial request with a limit parameter (optional — defaults vary by endpoint, max is your plan's row cap).
  2. Check meta.next_cursor in the response. If it's not null, more data is available.
  3. Pass the cursor value as the after query parameter on your next request.
  4. Repeat until next_cursor is null.

Parameters

ParameterTypeDescription
limitintegerMaximum rows to return per response. Cannot exceed your plan's max rows (Basic: 200, Pro: 1,000, Business: 1,000, Enterprise: 10,000).
afterstringOpaque cursor from a previous response's meta.next_cursor. Fetches the next page of results.

Row Capping

If the total result set exceeds your plan's max rows per response, the response is truncated and the X-Rows-Capped header is set to true. Use next_cursor to retrieve the remaining rows.

Even when you set limit below your plan cap, X-Rows-Capped will be false — it only indicates server-side truncation, not client-requested limits.

Example: Paginate All Results

This Python example fetches all 1-hour BTC candles from Binance for a given time range:

import requests

API_KEY = "YOUR_KEY"
BASE_URL = "https://kwery-api.com/v1/candles"

all_rows = []
cursor = None

while True:
    params = {
        "api-key": API_KEY,
        "symbol": "BTCUSDT",
        "source": "binance",
        "interval": "1h",
        "start": "2025-01-01T00:00:00Z",
        "end": "2025-01-15T00:00:00Z",
        "limit": 1000,
    }
    if cursor:
        params["after"] = cursor

    resp = requests.get(BASE_URL, params=params)
    resp.raise_for_status()
    body = resp.json()

    all_rows.extend(body["data"])
    cursor = body["meta"]["next_cursor"]

    if cursor is None:
        break

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

Credit Impact

Each paginated request is a separate API call. Every page consumes credits according to the endpoint's credit formula (base cost + per-row cost) and counts against your rate limits. Plan pagination into your credit budget accordingly.