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

# Pagination

> Fetching large datasets with cursor-based pagination.

All list endpoints use **cursor-based pagination**. This is more efficient than offset pagination for large datasets and is stable under concurrent writes.

## How it works

Every list response includes a `pagination` object:

```json theme={null}
{
  "data": [...],
  "pagination": {
    "next_cursor": "MTcxODQwMDAwMDAwMC00Mg==",
    "has_more": true
  }
}
```

* `has_more: true` means there are more results to fetch
* `next_cursor` is an opaque string — pass it as the `cursor` query parameter to get the next page
* When `has_more` is `false`, you have reached the last page and `next_cursor` is `null`

## Fetching all pages

<CodeGroup>
  ```typescript TypeScript theme={null}
  const client = new Ironflow("if_your_api_key");

  // The Page object has built-in next() support
  let page = await client.trades("BTC-PERP", { limit: 100 });
  const allTrades = [...page.data];

  while (page.hasMore) {
    page = await page.next();
    allTrades.push(...page.data);
  }

  console.log(`Fetched ${allTrades.length} trades`);
  ```

  ```python Python theme={null}
  async with Ironflow("if_your_api_key") as client:
      page = await client.trades("BTC-PERP", limit=100)
      all_trades = list(page.data)

      while page.has_more:
          page = await page.next()
          all_trades.extend(page.data)

      print(f"Fetched {len(all_trades)} trades")
  ```

  ```bash cURL theme={null}
  # Page 1
  curl "https://api.ironflow.sh/v1/trades?source=hyperliquid&market=BTC-PERP&limit=100" \
    -H "Authorization: Bearer if_your_api_key"

  # Page 2 — use cursor from previous response
  curl "https://api.ironflow.sh/v1/trades?source=hyperliquid&market=BTC-PERP&limit=100&cursor=MTcxODQwMDAwMDAwMC00Mg==" \
    -H "Authorization: Bearer if_your_api_key"
  ```
</CodeGroup>

## Parameters

| Parameter | Default | Max |
| - | - | - |
| `limit` | 100 | 1000 |
| `cursor` | — | — |

## Tips

* **Use `from`/`to` to scope your query.** Paginating across years of tick data without a time range will be slow. Always specify `from` and `to` for large exports.
* **Cursors are not permanent.** Don't store cursors for later use — they encode a position within a specific query and may expire.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.