# Rate limits

60 requests a minute per IP address, in bursts of up to 30, reported in RateLimit headers on counted responses.

Each client IP address may make **60 requests a minute**, in bursts of up to **30**.
The allowance refills continuously, one request a second: after spending a burst of 30 you can make another request a second later, and the full 30 are back after 30 seconds without a request.

## Headers

| Header | Meaning |
| --- | --- |
| `RateLimit-Limit` | The most requests you can make in a burst: `30`. It is the burst, not the per-minute rate. |
| `RateLimit-Remaining` | How many requests you can make right now. |
| `RateLimit-Reset` | Seconds until your burst is full again. |

These headers are on responses to requests the limit counts.
A browser's CORS preflight (`OPTIONS`) is answered before the limit, is not counted, and carries none of them.

`RateLimit-Limit` is on every counted response.
`RateLimit-Remaining` and `RateLimit-Reset` are only on the counted responses no cache may share - errors, including a `429`, and `POST`s.
A successful `GET` can be cached and handed to another caller (see [CORS and caching](https://developers.drophawk.net/guides/cors-and-caching.md)), so it cannot carry your allowance; serving it from a cache costs you nothing anyway.

All of them are exposed to browsers, so a page calling the API can read them.

## When you are limited

Over the limit, the API answers `429 Too Many Requests` with a `Retry-After` header giving the number of seconds to wait.
The body is the usual error, with the reason `RATE_LIMITED` and the same wait in `retry_after_seconds`:

```http
HTTP/1.1 429 Too Many Requests
Retry-After: 1
Content-Type: application/json

{
  "code": 8,
  "message": "resource_exhausted",
  "details": [
    {
      "@type": "type.googleapis.com/google.rpc.ErrorInfo",
      "reason": "RATE_LIMITED",
      "domain": "drophawk.net",
      "metadata": { "retry_after_seconds": "1" }
    }
  ]
}
```

Wait at least that long before the next request.
A request sent sooner is refused too.

## Staying under it

- Cache responses: a successful `GET` may be cached for five minutes (see [CORS and caching](https://developers.drophawk.net/guides/cors-and-caching.md)).
  The trade-off is that a cached answer can miss a Sync that finished in the last five minutes.
- A server that calls the API on behalf of many users shares one IP address, and so one allowance.
  Cache on your side rather than passing each user's request through.

If the limit gets in the way of something you are building, email [support@drophawk.net](mailto:support@drophawk.net) and say what it is.
