# Stay within rate limits

> How many requests an API key can make, the headers that show what's left, and what to do when you hit the limit.

Each API key has its own limits, so one busy script doesn't slow down another. Every response tells you how much room is left.

## The limits

| What | Limit per key |
|---|---|
| All requests | 600 a minute |
| Requests that make changes (`POST`, `PATCH`, `DELETE`) | 60 a minute, counted inside the 600 |

All of your team's keys together also share a larger limit. You'll only reach it with many busy keys at once.

Exports also use your team's monthly credits, the same as exporting in Onsite.

## Rate limit headers

Every successful response includes these headers, so your code can slow down before it reaches the limit:

<ResponseField name="RateLimit-Limit" type="integer">
  Requests the key can make in one window. `600`.
</ResponseField>

<ResponseField name="RateLimit-Remaining" type="integer">
  Requests left in the current window.
</ResponseField>

<ResponseField name="RateLimit-Policy" type="string">
  The limit and the window in seconds, such as `600;w=60`.
</ResponseField>

<ResponseField name="Retry-After" type="integer">
  Only on a `429`: seconds to wait before the next request.
</ResponseField>

## When you hit the limit

The API answers `429` with the code `rate_limited`:

```json
{
  "error": {
    "code": "rate_limited",
    "message": "Too many requests for this key. Wait for the time in the Retry-After header, then try again.",
    "requestId": "E-3PQ8-W2LC"
  }
}
```

Wait for the `Retry-After` seconds, then send the request again. [Errors](/api/errors#retry-safely) has a retry example.

## Make fewer requests

- **Ask for more rows at once.** Lists take `limit` up to their maximum, so one request can replace several. See [Pagination](/api/pagination).
- **Filter on the server.** Use parameters like `query`, `page`, `country` or `device` instead of fetching everything and filtering in your code.
- **Cache what doesn't change often.** A report for a period that has ended rarely changes, so keep its answer for a few hours.
- **Spread out scheduled jobs.** If a script reads many sites, read them one after another instead of all at once.

## Related

<CardGroup cols={2}>
  <Card title="Errors" icon="circle-alert" href="/api/errors">
    Every error code and how to retry safely.
  </Card>
  <Card title="Pagination" icon="list" href="/api/pagination">
    Get long lists in fewer requests.
  </Card>
</CardGroup>
