Developers
Rate limits
Each API key can make 120 requests per minute. Every response tells you where you stand.
Headers
| Header | Meaning |
|---|---|
RateLimit-Limit | Requests allowed per window (120). |
RateLimit-Remaining | Requests left in the current window. |
RateLimit-Reset | Seconds until the window resets. |
Retry-After | Only on 429: seconds to wait before retrying. |
HTTP/1.1 429 Too Many Requests
Content-Type: application/json
RateLimit-Limit: 120
RateLimit-Remaining: 0
RateLimit-Reset: 23
Retry-After: 23
{"error":{"code":"rate_limited","message":"Too many requests. Retry in 23 seconds."}}Staying under the limit
- Use webhooks instead of polling for changes.
- Ask for 100 items per page when you walk a list.
- Use
updated_sinceto fetch only what changed. - On
429, wait forRetry-Afterand retry; do not retry in a tight loop.
async function instaenvFetch(url, init = {}, attempt = 0) {
const res = await fetch(url, init);
if (res.status === 429 && attempt < 5) {
const waitSeconds = Number(res.headers.get("Retry-After")) || 2 ** attempt;
await new Promise((resolve) => setTimeout(resolve, waitSeconds * 1000));
return instaenvFetch(url, init, attempt + 1);
}
return res;
}