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

# Rate Limits

> Understand API rate limiting and best practices

# Rate Limits

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

## Current Limits

| Scope          | Limit                          |
| -------------- | ------------------------------ |
| Per IP address | **60 requests per 10 seconds** |

When you exceed the rate limit, the API returns a `429 Too Many Requests` response:

```json theme={null}
{
  "error": "Rate limit exceeded. Try again shortly."
}
```

## Best Practices

<CardGroup cols={2}>
  <Card title="Batch where possible" icon="layer-group">
    Use list endpoints with pagination instead of fetching resources one by one.
  </Card>

  <Card title="Cache responses" icon="database">
    Cache API responses on your end to reduce the number of requests, especially for data that doesn't change frequently (events, ticket classes).
  </Card>

  <Card title="Use exponential backoff" icon="rotate-right">
    When you receive a `429`, wait before retrying. Double the wait time on each subsequent retry.
  </Card>

  <Card title="Spread requests over time" icon="clock">
    If syncing large datasets, spread requests evenly rather than bursting all at once.
  </Card>
</CardGroup>

## Retry Strategy Example

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

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

    const delay = Math.pow(2, attempt) * 1000; // 1s, 2s, 4s
    await new Promise((r) => setTimeout(r, delay));
  }

  throw new Error("Rate limit exceeded after retries");
}
```
