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

# Pages and streams

> Page through results with next_cursor, or stream a whole window in one request and resume it if it breaks.

You can read history in two ways. Pick by size.

| Way | Best for | How |
| - | - | - |
| Pages | Small windows, discovery lists | JSON pages, following `next_cursor` |
| Streams | Large windows of one market | One request, NDJSON or CSV rows |

## Pages

Lists and history endpoints return one page at a time, with `next_cursor`. Pass it back as `cursor`, with the same parameters, until it is null. `limit` sets the page size: up to 1,000 items on lists (100 by default); each history endpoint's reference gives its own.

```bash theme={null}
# NEXT_CURSOR: the next_cursor of the page before
curl -s "https://api.qelso.io/v2/markets/polymarket:3215007/prices?start=2026-11-10&end=2026-11-17&resolution=10m&cursor=$NEXT_CURSOR" \
  -H "X-API-Key: $QELSO_API_KEY"
```

Cursors are opaque, tied to the request that produced them, and valid for 24 hours. On history endpoints, a paging run serves the data available when its first page was served, so its pages never skip or repeat a row (unless the data is corrected while you page). Data that arrives later appears when you request again.

The Python SDK pages for you: `client.iter_market_prices(...)` yields every row of every page.

## Streams

History and tick endpoints also stream: one request returns every row of the window, however many there are. Send one of these `Accept` headers:

| `Accept` | You get |
| - | - |
| `application/x-ndjson` | One JSON row per line, the same objects as in a page's `data` |
| `text/csv` | A header row, then one row per line; an empty cell is null |

Books stream as NDJSON only. Discovery and lifecycle don't stream. Send `Accept-Encoding: gzip` for large streams.

A stream costs what one page of its endpoint costs, and covers a longer window than a page:

| Endpoints | Window per stream |
| - | - |
| Prices, candles, statistics and books at `1m` to `1d` | 366 days |
| Sub-minute prices, candles and books; best bid and ask; book changes | 24 hours |
| Trades | 31 days |

Streams carry rows only. For Kalshi data, the attribution and the data type come in the `Qelso-Attribution` and `Qelso-Data-Type` response headers.

### When a stream breaks

A stream that ends normally has delivered every row we hold for the window. If anything fails after the first byte, the connection closes without finishing the response, so your HTTP client raises an error rather than ending quietly. Resume with `after=` set to the last row you received:

| Endpoint | `after=` |
| - | - |
| Prices, candles, statistics, books | `<t>` of the last row |
| Best bid and ask, trades | `<ts>,<seq>` of the last row |
| Book changes | `<ts>,<seq>,<side>,<price>` of the last row |

```bash theme={null}
curl -s "https://api.qelso.io/v2/markets/polymarket:3215007/trades?start=2026-11-16&end=2026-11-17&after=2026-11-16T00:29:01.000Z,2" \
  -H "X-API-Key: $QELSO_API_KEY" -H "Accept: application/x-ndjson"
```

Take the values from the last complete line, exactly as they were written (with `outcome=no`, the row's own side and price); a partial last line isn't a row. A resumed book-changes stream skips the starting book, so if it breaks before its first `update` row, start again without `after`.

> [!TIP]
>
> The Python SDK's `stream_*` methods do all of this: they resume a broken stream by themselves, without repeating or skipping a row, and wait out an outage once rows are flowing. `save(path)` writes a stream to a file (and `save(path, resume=True)` carries on one that failed), and `to_pandas()` reads it into a DataFrame.


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