Developers
Menu

Rate limits

Each API key has an allowance of requests a minute, set by the plan of the workspace in the path.

Plan Requests a minute, per key
Free 60
Every paid plan, and trials 600

Where you stand

Every response to a key carries three headers:

Header Meaning
X-RateLimit-Limit Your allowance this minute
X-RateLimit-Remaining Requests left in this minute
X-RateLimit-Reset Seconds until the minute ends and the count starts again
http
HTTP/1.1 200 OK
X-RateLimit-Limit: 600
X-RateLimit-Remaining: 587
X-RateLimit-Reset: 41

Over the limit

The request is refused with 429 and a Retry-After header, in seconds:

http
HTTP/1.1 429 Too Many Requests
Retry-After: 18
Content-Type: application/json

{
  "code": "RATE_LIMITED",
  "message": "Too many requests for this API key",
  "details": { "retryAfterS": 18, "limitPerMinute": 60 }
}

Nothing was done; send the same request again once Retry-After has passed.

Staying inside it

js
async function punchly(path, init = {}, attempt = 0) {
  const res = await fetch(`https://api.punchly.work/v1${path}`, {
    ...init,
    headers: { 'X-Api-Key': process.env.PUNCHLY_API_KEY, 'Content-Type': 'application/json', ...init.headers },
  });
  const safeToRepeat = res.status === 429 || (res.status >= 500 && (init.method ?? 'GET') === 'GET');
  if (safeToRepeat && attempt < 6) {
    const retryAfter = Number(res.headers.get('retry-after'));
    const wait = retryAfter > 0 ? retryAfter * 1000 : Math.min(60_000, 1000 * 2 ** attempt) * (0.5 + Math.random());
    await new Promise((resolve) => setTimeout(resolve, wait));
    return punchly(path, init, attempt + 1);
  }
  return res;
}

Need more than 600 a minute? Tell us what you're building.