← Errors and troubleshooting

HTTP 429 · RATE_LIMITED

RATE_LIMITED: too many requests in the last 60 seconds

Each key may make a fixed number of requests in any rolling 60-second window. Go over it and the API answers 429 RATE_LIMITED until enough of your earlier requests have aged out of the window. This one is safe to retry - after waiting.

Updated · every example recorded from a real API call

HTTP status
429 Too Many Requests (same status as QUOTA_EXCEEDED - switch on error.code)
Retry?
Yes, after the Retry-After header (the same number as details.retry_after_seconds).
Scope
Per API key, rolling 60-second window.
Counts toward your monthly quota?
No. A 429 is logged in your usage history but never billed.

The response and the headers around it

A Free key (60 per minute) sent 62 requests to GET /v1/ayanamsa in one second. The 60th succeeded with the budget at zero:

http
HTTP/1.1 200 OK
x-request-id: req_01M8RK47K5NVFK02A3A6FQF3SE
x-ratelimit-limit: 60
x-ratelimit-remaining: 0
x-ratelimit-reset: 1796121757

The 61st was refused, with the same budget headers plus retry-after:

http
HTTP/1.1 429 Too Many Requests
x-request-id: req_01M8RK47K6ZSB06S5FXRZNT6PS
x-ratelimit-limit: 60
x-ratelimit-remaining: 0
x-ratelimit-reset: 1796121757
retry-after: 60
json
{
  "request_id": "req_01M8RK47K6ZSB06S5FXRZNT6PS",
  "error": {
    "code": "RATE_LIMITED",
    "message": "Rate limit exceeded",
    "details": { "retry_after_seconds": 60 }
  }
}
  • Wait for `Retry-After`. It is the seconds until the oldest request in your window ages out, at least 1. Here all 60 landed in the same second, so it is the full 60. The body repeats it as details.retry_after_seconds - use that as a fallback if a proxy strips the header.
  • `x-ratelimit-reset` is when the window frees its next slot, as a Unix second: the oldest request in the window plus 60 s. The first call into an empty window shows roughly now + 60. The 1st, 60th, 61st and 62nd responses here all carry the same value because they arrived within one second.
  • Throttle on `x-ratelimit-remaining` from your successful responses, before you hit the wall: at 0, sleep until x-ratelimit-reset instead of sending a request that will be refused.
  • A retried 429 costs no quota - refused calls are logged but not billed (62 calls in our test billed 60) - but it does nothing useful either: refused requests are not added to the window, so hammering neither extends nor shortens the wait. See QUOTA_EXCEEDED.
Per-minute rate limit by plan
PlanRequests per 60 s (per key)
Free60
Hobby180
Starter600
Pro6,000

A backoff loop that respects the body

Retry only RATE_LIMITED, waiting for Retry-After; give up on everything else, including QUOTA_EXCEEDED.

ts
async function postWithBackoff(path: string, body: unknown, maxAttempts = 4): Promise<Response> {
  for (let attempt = 1; ; attempt++) {
    const res = await fetch(`https://api.astronode.dev${path}`, {
      method: "POST",
      headers: {
        Authorization: `Bearer ${process.env.ASTRONODE_KEY}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify(body),
    });
    if (res.status !== 429 || attempt === maxAttempts) return res;

    const { error } = await res.clone().json();
    if (error.code !== "RATE_LIMITED") return res; // quota: waiting will not help

    const header = Number(res.headers.get("retry-after"));
    const waitS = header > 0 ? header : (error.details?.retry_after_seconds ?? 2 ** attempt);
    await new Promise((r) => setTimeout(r, waitS * 1000 + Math.random() * 500));
  }
}

The jitter matters when several workers share a key: without it they all wake at the same moment and trip the limit together again.

Avoiding it in the first place

  • Spread batch jobs: 60 per minute is one request a second; at 600 (Starter) one every 100 ms.
  • Scoring many couples? POST /v1/compatibility/batch takes up to 500 pairs in one request.
  • Need several dasha systems or charts for one person? Cache the birth chart and reuse it rather than recomputing per screen.
  • The limit is per key, the quota per account - splitting traffic across keys changes the first, never the second.

Questions

Does the AstroNode API send a Retry-After header?
Yes, on every 429. For RATE_LIMITED it equals details.retry_after_seconds in the body; for QUOTA_EXCEEDED it is the seconds until the monthly quota resets.
Do rate-limited requests count toward my monthly quota?
No. Rate-limited requests are logged but only successful calls are billed. Retrying without waiting still achieves nothing, because the window only frees up as your earlier successful requests age out.