> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nextsportsapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Handle Rate Limits

> Use headers, caching, and backoff to keep integrations stable.

Production integrations should read rate limit headers, cache low-change data, and retry safely.

## Read usage headers

```http theme={"system"}
X-RateLimit-Limit: 600
X-RateLimit-Remaining: 590
X-RateLimit-Reset: 1780000000
X-Quota-Limit: 50000
X-Quota-Remaining: 48750
```

## Backoff on `429`

When the API returns `429 Too Many Requests`, stop sending requests until the reset time. If no reset header is available, use exponential backoff.

```js theme={"system"}
async function requestWithBackoff(url, apiKey) {
  let delay = 1000;

  for (let attempt = 0; attempt < 5; attempt += 1) {
    const response = await fetch(url, {
      headers: {
        Authorization: `Bearer ${apiKey}`,
      },
    });

    if (response.status !== 429) {
      return response;
    }

    const reset = response.headers.get("X-RateLimit-Reset");
    const waitMs = reset ? Math.max(Number(reset) * 1000 - Date.now(), delay) : delay;
    await new Promise((resolve) => setTimeout(resolve, waitMs));
    delay *= 2;
  }

  throw new Error("Rate limit retry attempts exhausted");
}
```

## Cache strategy

| Endpoint family               | Cache strategy                                         |
| ----------------------------- | ------------------------------------------------------ |
| Timezones, countries, seasons | Long-lived cache.                                      |
| Leagues and teams             | Daily cache.                                           |
| Fixtures                      | Cache by date, league, season, status, and fixture ID. |
| Standings                     | Hourly for active leagues, daily otherwise.            |
| Live fixtures                 | Short cache only while live.                           |
