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

# Rate Limiting

> Understand API rate limits and how to handle them.

The API enforces rate limits to ensure fair usage and protect service stability.

## Default limits

| Limit               | Value      |
| ------------------- | ---------- |
| Requests per minute | 500 per IP |

Rate limits are applied per IP address across all endpoints.

## Rate limit headers

When you approach the limit, monitor these response headers:

| Header                  | Description                              |
| ----------------------- | ---------------------------------------- |
| `X-RateLimit-Limit`     | Maximum requests allowed per window      |
| `X-RateLimit-Remaining` | Requests remaining in the current window |
| `X-RateLimit-Reset`     | Unix timestamp when the window resets    |

## Handling 429 responses

When you exceed the rate limit, the API returns a `429 Too Many Requests` status. Implement exponential backoff to retry:

<CodeGroup>
  ```python Python theme={null}
  import time
  import requests

  def api_request(url, headers, max_retries=3):
      for attempt in range(max_retries):
          response = requests.get(url, headers=headers)

          if response.status_code == 429:
              wait = 2 ** attempt
              print(f"Rate limited. Retrying in {wait}s...")
              time.sleep(wait)
              continue

          return response

      raise Exception("Max retries exceeded")
  ```

  ```javascript JavaScript theme={null}
  async function apiRequest(url, headers, maxRetries = 3) {
    for (let attempt = 0; attempt < maxRetries; attempt++) {
      const response = await fetch(url, { headers });

      if (response.status === 429) {
        const wait = 2 ** attempt * 1000;
        console.log(`Rate limited. Retrying in ${wait}ms...`);
        await new Promise((r) => setTimeout(r, wait));
        continue;
      }

      return response;
    }

    throw new Error("Max retries exceeded");
  }
  ```
</CodeGroup>

## Best practices

* **Use pagination** with `page_size=100` to reduce total requests
* **Use bulk endpoints** (e.g., `bulk-delete`) instead of individual calls
* **Cache responses** when data doesn't change frequently
* **Spread requests** evenly rather than bursting
