# Rate limits

How many calls you can make, and what happens when you reach the limit.

## Limits per key

| Limit | Value |
| --- | --- |
| Per minute | 60 calls |
| Per day | 5,000 calls, resets at 00:00 Western Indonesia Time (UTC+7) |
| Rows per page | 100 |
| Reports | 30 files per day, the same request within 60 minutes is not counted |

## Checking your quota

Usage per day, per key, and per endpoint is in the Wefluence app, under **Settings**, then **API key**.

Every response carries these headers:

| Header | Contents |
| --- | --- |
| `X-RateLimit-Limit` | Limit per minute |
| `X-RateLimit-Remaining` | Calls left this minute |
| `X-RateLimit-Reset` | Reset time, in Unix seconds |
| `X-Daily-Limit` | Limit per day |
| `X-Daily-Remaining` | Calls left today |

## When you hit the limit

The API answers `429` with a `Retry-After` header in seconds. Wait that long before trying again.

```python
import time

r = requests.get(url, headers=headers)
if r.status_code == 429:
    time.sleep(int(r.headers.get("Retry-After", "60")))
```
## Saving calls

- Pull only active campaigns. A finished campaign only needs one more pull after it ends.
- Need all content at once? A [report](https://docs.wefluence.app/en/reference/reports/) costs one call, however much content there is.
- Need only the best content? [Top content](https://docs.wefluence.app/en/reference/content/) costs one call.
- Stats are cached for up to 60 minutes, or 24 hours for finished campaigns. Calling more often does not make the numbers fresher.
- Send `If-None-Match` with the last `ETag` to [Campaign stats](https://docs.wefluence.app/en/reference/campaign-stats/). The API answers `304` with no body when nothing has changed.
