> ## Documentation Index
> Fetch the complete documentation index at: https://docs.radion.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Pagination

> How cursor-based pagination works on list endpoints in the Radion API.

List endpoints use cursors to move through pages. A cursor is an opaque string. You do not read it; you just send it back. Pass `cursor` and `limit` as query parameters.

## Parameters

| Parameter | Type    | Default | Range | What it does                                                              |
| --------- | ------- | ------- | ----- | ------------------------------------------------------------------------- |
| `limit`   | integer | 50      | 1–200 | How many items to return per page.                                        |
| `cursor`  | string  | —       | —     | The `nextCursor` from the page before. Leave it out on the first request. |

## What a page looks like

Events and markets list responses use a named array and a `nextCursor` field:

```json theme={null}
{
  "events": [...],
  "nextCursor": "eyJjb21wdXRlZF9hdCI6Ij..."
}
```

`nextCursor` is `null` when there are no more pages.

## Getting every page

<CodeGroup>
  ```bash cURL theme={null}
  # First page
  curl "https://api.radion.app/v1/polymarket/events?limit=50" \
    -H "X-API-Key: YOUR_API_KEY"

  # Next page (use nextCursor from the page before)
  curl "https://api.radion.app/v1/polymarket/events?limit=50&cursor=NEXT_CURSOR" \
    -H "X-API-Key: YOUR_API_KEY"
  ```

  ```typescript TypeScript theme={null}
  async function* listAllEvents(apiKey: string) {
    let cursor: string | undefined;

    while (true) {
      const url = new URL("https://api.radion.app/v1/polymarket/events");
      url.searchParams.set("limit", "50");
      if (cursor) url.searchParams.set("cursor", cursor);

      const res = await fetch(url.toString(), {
        headers: { "X-API-Key": apiKey },
      });
      const { events, nextCursor } = await res.json();

      yield* events;

      if (!nextCursor) break;
      cursor = nextCursor;
    }
  }

  for await (const event of listAllEvents("YOUR_API_KEY")) {
    console.log(event.id, event.title, event.volume);
  }
  ```

  ```python Python theme={null}
  import httpx

  def list_all_events(api_key: str):
      client = httpx.Client(
          base_url="https://api.radion.app",
          headers={"X-API-Key": api_key},
      )
      cursor = None
      while True:
          params = {"limit": 50}
          if cursor:
              params["cursor"] = cursor
          body = client.get("/v1/polymarket/events", params=params).json()
          yield from body["events"]
          cursor = body.get("nextCursor")
          if not cursor:
              break

  for event in list_all_events("YOUR_API_KEY"):
      print(event["id"], event["title"], event["volume"])
  ```
</CodeGroup>

## Knowing when to stop

Stop when `nextCursor` is `null`. Do not stop just because the array looks empty. Always check `nextCursor`.
