Conventions
Rate limits
Each API key has its own limit on requests per minute, and every response to a key says where it stands.
Limits per key
| Key | Requests per minute |
|---|---|
Organisation key, wwo_ | 100 |
Personal key, wwp_ | 30 |
Requests are counted in windows of one minute. A window starts with the key’s first request and lasts 60 seconds; the first request after it ends starts the next one.
The limits are the same for every key of a kind, whatever its organisation or plan. To get more done within them, see staying under.
Headers
Once the API has checked the key and its scopes, it counts the request, and the response carries two headers. A request refused before that (401, 403 insufficient_scope from the scope check, or 404 for another organisation or a path no operation has) is not counted and has neither header. Two refusals come after the count and carry both headers: 403 plan_required, and 403 insufficient_scope for a key that tries to invite a trainer.
RateLimit-Policy: "key";q=100;w=60
RateLimit: "key";a=57;w=23RateLimit-Policy: the key’s quotaqfor each window ofwseconds.RateLimit:arequests left in the current window, which ends inwseconds.
The headers follow the IETF draft draft-ietf-httpapi-ratelimit-headers-12, and will follow the RFC once it is published. That change will be in the changelog.
Going over
A request over the limit gets 429 RATE_LIMITED with a Retry-After header: the seconds until the window ends. details.retryAfter holds the same number. Requests sent before then fail too, so wait.
// Calls the API, waiting and retrying when the key is over its limit.
async function callWithRetry(url, init, attempts = 5) {
for (let i = 0; i < attempts; i++) {
const res = await fetch(url, init);
if (res.status !== 429) return res;
const seconds = Number(res.headers.get('Retry-After') ?? '1');
await new Promise((resolve) => setTimeout(resolve, seconds * 1000));
}
throw new Error(`Still rate limited after ${attempts} attempts`);
}Staying under
- Watch
ain theRateLimitheader, and slow down as it nears 0. - Use webhooks to hear about changes instead of polling for them.
- Assign a programme to up to 100 customers in one request.
- Read pages of 50 when you list everything.
The service also limits each credential to 120 requests a minute across all routes, to protect the service. The limits per key are lower, so you meet those first.
Other limits
| Limit | Value |
|---|---|
| Request body | 64 KiB; 128 KiB on programme routes |
Page size (limit) of a list with a cursor | 1 to 50, 20 when left out |
| Customers in one assignment request | 1 to 100 |
| Active programmes a customer can have, their own and assigned | 30, their own within their plan’s allowance |
| Active library programmes per organisation | 500, within the plan’s allowance |
| Active exercises and machines per organisation | 300 exercises, 200 machines |
| Pending invitations per organisation | 1,000 |
| Linked customers per organisation | 5,000 |
| Members of a gym | 100 |
| Webhook endpoints per organisation | 10 |
| Active API keys | The plan’s allowance, and 20 per account |
| Stations per programme, sets per station | 15 stations, 10 sets |
| Plan size the watch downloads | 6,000 bytes |