> ## Documentation Index
> Fetch the complete documentation index at: https://sonar-cf3aeac7.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Pagination and limits

> Cursor pagination for trades, offset paging for Pulse, every REST limit and default, WebSocket limits and data freshness.

ChainQuery uses three paging styles:

| Style | Endpoints |
| - | - |
| Cursor | [`GET /trades`](https://sonar-cf3aeac7.mintlify.site/api-reference/trades/get-trades) |
| Limit and offset | Pulse: [`POST /pulse/views`](https://sonar-cf3aeac7.mintlify.site/pulse/rest-views), [`POST /pulse`](https://sonar-cf3aeac7.mintlify.site/pulse/native-views) |
| Limit only (no paging) | Every other REST route |

There are no pagination headers. Everything is in the response body.

## Cursor pagination (trades)

Every trade has an opaque `cursor` field. To fetch the next page:

1. Take the `cursor` of the **last** trade in the current page.
2. Send it as the `cursor` query parameter, with the **same** `address`, `chain`, `order`, `from` and `to`.
3. Stop when a page has fewer items than `limit` (including an empty page).

There is no `nextCursor` or `hasMore` field.

```bash theme={null}
# Page 1 (newest first)
curl "https://api.example.com/api/v1/trades?chain=8453&address=0x4200000000000000000000000000000000000006&limit=100"

# Page 2
curl "https://api.example.com/api/v1/trades?chain=8453&address=0x4200000000000000000000000000000000000006&limit=100&cursor=MTc5NDIxODQwMDAwMC4yMzAwMDAwMC4zLjcuMzkxNDQ2MDQyMDQ"
```

How the cursor behaves:

* The cursor is exclusive: the next page starts strictly after that trade in the chosen `order` (`desc` = older trades, `asc` = newer trades).
* The cursor does not store the order or the query. Sent with a different `order` it seeks in the other direction, and sent with a different `address` it is just a position in time. Always reuse it with the same query.
* `from`/`to` combine with the cursor, so you can page inside a time window.
* Treat the cursor as opaque. Do not build or parse it. A malformed cursor returns `400 INVALID_PARAMETERS` with `cursor: invalid cursor`. A cursor longer than 128 characters is also rejected with `400 INVALID_PARAMETERS`, with a length message such as `cursor: Too big: expected string to have <=128 characters`.
* Ordering is total and stable: by time, then block, transaction index, log index and trade id.

> [!NOTE]
>
> When `address` is a token, trades are merged from that token's **two** most active pools (by 24h volume, then liquidity). Trades in its other pools are not included. Query a pool address to page through one specific pool.

## Limit and offset (Pulse)

Pulse views take `limit` (1 to 100) and `offset` (0 to **500**) per view. The deepest reachable result is position 600 (`offset` 500 + `limit` 100).

To show a total or a page count, send the same body to [`POST /pulse/views/pagination`](https://sonar-cf3aeac7.mintlify.site/pulse/rest-views-pagination). It returns the total number of matching tokens per view, which can be larger than what you can page to:

```json theme={null}
{ "hot": { "pagination": 1250 } }
```

`offset` is only available over REST. The [Pulse stream](https://sonar-cf3aeac7.mintlify.site/pulse/stream.md) rejects `offset` greater than 0.

## REST limits and defaults

| Endpoint | Parameter | Default | Range |
| - | - | - | - |
| `GET /trades` | `limit` | 10 | 1 to 100 |
| `GET /token/ohlcv`, `GET /market/ohlcv`, `GET /asset/ohlcv` | `limit` (candles) | 500 | 1 to 2000 |
| `GET /token/markets` | `limit` (pools) | 10 | 1 to 25 |
| `GET /wallet/holdings` | `limit` (holdings) | 100 | 1 to 500 |
| `GET /search` | `limit` | 10 | 1 to 20 (for `type=all`, applied to tokens and pools separately) |
| `POST /market/details` | items in the body array | | 1 to 100 |
| `GET /token/history`, `GET /asset/history` | points returned | | at most 2000 (the oldest points are dropped) |
| `POST /pulse`, `POST /pulse/views` | views per request | | 1 to 10 |
| `POST /pulse`, `POST /pulse/views` | `limit` per view | 30 | 1 to 100 |
| `POST /pulse`, `POST /pulse/views` | `offset` per view | 0 | 0 to 500 |

A value outside its range returns `400 INVALID_PARAMETERS`, for example `limit: Too big: expected number to be <=100`.

Some limit-only routes also report a total so you can show "N of M":

* `GET /token/markets` returns `totalCount`, the number of the token's pools with stats.
* `GET /wallet/holdings` returns `holdingsCount` and `totalBalanceUSD` computed over **all** holdings that passed the filters, before `limit` is applied.

## WebSocket limits

The channel WebSocket and the multi-events stream share these current defaults per connection:

| Limit | Default | When exceeded |
| - | - | - |
| Messages you send | 20 per second | Connection closed with code `4029` |
| Message size | 64 KiB | Connection closed with code `1009` |
| Subscription weight | 100 | `SUBSCRIPTION_LIMIT` error; the subscription is refused |
| Unsent data buffered for you | 4 MiB | Connection closed with code `4008` (slow consumer) |
| Resume history | About 10 minutes | `RESUME_EXPIRED` error |

Details: [WebSocket limits and errors](https://sonar-cf3aeac7.mintlify.site/websocket/limits-and-errors.md), [Multi-events limits and cost](https://sonar-cf3aeac7.mintlify.site/streams/limits-and-cost.md) and, for the separate Pulse stream, [Pulse stream](https://sonar-cf3aeac7.mintlify.site/pulse/stream.md).

## Authentication and rate limiting

The REST API currently has no authentication and no rate limiting. No API key is required. This is expected to change before a production launch, so build in handling for `401`, `403` and `429` responses.

## Freshness

Responses carry no `Cache-Control` or `ETag` headers. Some data is cached briefly on the server, so repeated calls inside these windows can return the same values:

| Data | Approximate server-side freshness |
| - | - |
| `GET /protocols` | About 5 minutes |
| Pulse REST views (database-backed answers) and pagination totals | About 30 seconds |
| Native coin balance in `GET /wallet/holdings` | About 5 seconds |
| Rolling token and pool stats | Recomputed continuously, typically within about a minute |

For live data, use the [WebSocket channels](https://sonar-cf3aeac7.mintlify.site/websocket/overview.md) instead of polling.


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