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/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/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
{
"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-resetinstead 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.
| Plan | Requests per 60 s (per key) |
|---|---|
| Free | 60 |
| Hobby | 180 |
| Starter | 600 |
| Pro | 6,000 |
A backoff loop that respects the body
Retry only RATE_LIMITED, waiting for Retry-After; give up on everything else, including QUOTA_EXCEEDED.
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/batchtakes 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.