# Rate limits

> Each account, across all its keys, can make 120 requests a minute, read 5,000 trades older than an hour, open 100 different traders and list traders 10 times a day, and hold three streams open at once. Trades from the last hour are free.

Source: https://rivo.markets/docs/rate-limits

| Limit | Per account, all keys together | Resets |
| --- | --- | --- |
| Requests | 120 a minute | Every minute |
| Trades read | 5,000 trades older than an hour a day, across `/v2/trades` and `include=trades`. Trades from the last hour on `/v2/trades` and the stream do not count | Midnight UTC |
| Traders opened | 100 different traders a day, from `/v2/traders/{ref}`. A trader opened again the same day does not count again | Midnight UTC |
| Trader listings | 10 calls a day to `/v2/traders`, each stopping at the top 100 | Midnight UTC |
| Streams open at once | 3, shared with `/v1/stream`. A fourth closes the oldest | When one closes |
| Trade history | The last 30 days | Rolling |

## What counts as a request

- Every call is one request.
- Each `include` counts as one more request.
- A backtest `sweep` counts one request for each value it scores.
- An open stream counts as one request for each minute it stays open.

## Headers

Every response tells you how much of your limit is left, so your client can slow down before it hits the limit.

| Header | Means |
| --- | --- |
| `x-ratelimit-limit` | The number of requests you can make each minute. |
| `x-ratelimit-remaining` | The number of requests you have left this minute. |
| `x-ratelimit-reset` | The number of seconds until the minute resets. |
| `retry-after` | On a 429, the number of seconds to wait before you try again. |
| `x-trades-limit` | On trade listings, the number of trades you can read each day. |
| `x-trades-remaining` | On trade listings, the number of trades you have left today. |
| `x-trades-reset` | On trade listings, the number of seconds until midnight UTC. |
| `x-traders-limit` | On one trader, the number of different traders you can open each day. |
| `x-traders-remaining` | On one trader, the number of new traders you can still open today. |
| `x-traders-reset` | On one trader, the number of seconds until midnight UTC. |
| `x-trader-lists-limit` | On trader listings, the number of listings you can make each day. |
| `x-trader-lists-remaining` | On trader listings, the number of listings you have left today. |
| `x-trader-lists-reset` | On trader listings, the number of seconds until midnight UTC. |

## When you hit a limit

When you go over a limit, the API answers `429 QUOTA_EXCEEDED`. Wait the number of seconds in `retry-after`, then send the same request again.

## Staying under the limits

- Use the [stream](https://rivo.markets/docs/streaming) for live data instead of polling.
- Set `limit=200` when you read many pages. Fewer, larger pages use fewer requests.
- Filter on the server with `minWinRate`, `minSettled` and `minUsd`. The API does not send or count trades that your filters leave out.
- Cache what single-market and single-trader routes return. Those records change slowly, so caching them for a few minutes is safe.
