# Limits

https://gorally.games/en/developers/limits

Each key has a request quota, a per-request time limit and a maximum body size. This guide says what to respect and what to do when a request is refused.

## Your key’s quota

Each key can send:

- 120 requests per minute;
- 3,000 requests per hour.

Beyond that, the API answers `429` with the `RATE_LIMITED` code. It adds the `Retry-After` header, the number of seconds to wait.

The quota is per key. Two keys have two quotas.

## What to do with a 429

1. Wait at least `Retry-After` seconds.
2. Send the request again.
3. If the `429` comes back, double the wait on each try and add a random delay.

```js
async function call(url, options, tries = 5) {
  for (let attempt = 0; attempt < tries; attempt += 1) {
    const response = await fetch(url, options);
    if (response.status !== 429) return response;
    const wait = Number(response.headers.get('Retry-After') ?? 1) * 2 ** attempt;
    await new Promise((done) => setTimeout(done, (wait + Math.random()) * 1000));
  }
  throw new Error('Quota still exceeded');
}
```

To avoid reaching it, ask for pages with a `limit` of 100. Also follow events by webhook instead of polling the API in a loop.

## The 10-second limit

A request that runs longer than 10 seconds is cut off. The API answers `503` with `LEAGUES_UNAVAILABLE` and `Retry-After: 30`.

A write that was cut off may have succeeded. Read the item or the events (`GET /events`) before sending it again.

If nothing was written, send it again with a new key. The same key can answer `409` without running anything: read the "Idempotency" guide.

## Body size

A request body is at most 16 KiB. Beyond that, the API answers `413` with `BODY_TOO_LARGE`.

The API carries no files: shrink the body, do not split it.

## Changes to the limits

These values may change. Any change is announced with notice. The "Versions and terms of use" page explains how, and the changelog dates it.

## What next

- Read the "Errors" guide again for the full list of codes.
