Guides

Pagination

The /v2/events endpoint can return thousands of results. Results are delivered in batches using cursor-based pagination.

How It Works

  1. Make a request. Each request returns up to limit items.
  2. If more items are available, the response includes a nextCursor field.
  3. Repeat the request with cursor=<nextCursor value> to get the next page.
  4. Continue until no nextCursor is returned — you've reached the end.

The cursor Parameter

  • Always use the value exactly as returned — don't modify it.
  • Don't change other query parameters between paginated requests.
  • If you pass a cursor and receive a 404, you've reached the end of the results.

The limit Parameter

  • Default is 10 if not specified.
  • Maximum is 300.
  • The effective limit may be lower depending on query complexity (e.g. including alt lines reduces it).

1 object = 1 event, regardless of how many odds markets are returned inside it. 10 events = 10 objects against your quota, even if each event contains hundreds of odds.

Example — Fetch All Open Kalshi Events

JavaScript

const allEvents = [];
let nextCursor = null;
let hasMore = true;

while (hasMore) {
  try {
    const params = new URLSearchParams({
      bookmakerID: "kalshi",
      oddsAvailable: "true",
      limit: "100",
      ...(nextCursor ? { cursor: nextCursor } : {}),
    });

    const response = await fetch(
      `https://api.sportsgameodds.com/v2/events?${params}`,
      { headers: { "x-api-key": YOUR_API_KEY } }
    );

    const data = await response.json();
    allEvents.push(...data.data);
    nextCursor = data.nextCursor;
    hasMore = Boolean(nextCursor);
  } catch {
    hasMore = false;
  }
}

console.log(`Fetched ${allEvents.length} events`);

Python

import requests

all_events = []
next_cursor = None
has_more = True

while has_more:
    params = {
        "bookmakerID": "kalshi",
        "oddsAvailable": "true",
        "limit": 100,
    }
    if next_cursor:
        params["cursor"] = next_cursor

    data = requests.get(
        "https://api.sportsgameodds.com/v2/events",
        headers={"x-api-key": YOUR_API_KEY},
        params=params
    ).json()

    all_events.extend(data.get("data", []))
    next_cursor = data.get("nextCursor")
    has_more = next_cursor is not None

print(f"Fetched {len(all_events)} events")

Always set limit as high as your use case allows before adding cursor pagination — fewer round trips means faster ingestion and fewer requests against your quota.