The spec
The spec is served at https://api.astronode.dev/v1/openapi.json. It is OpenAPI 3.1, needs no API key to download, and is generated from the same route schemas that validate requests, so the fields it describes are the ones the server checks. It declares bearer authentication and the production server URL.
Each operation documents its real error responses, not just 200: 400 VALIDATION_ERROR, 401 UNAUTHORIZED, 403 PLAN_REQUIRED naming the plan the endpoint needs, 409 IDEMPOTENCY_KEY_REUSED on POSTs, 429 RATE_LIMITED / QUOTA_EXCEEDED with the Retry-After and x-ratelimit-* headers, and 500 INTERNAL_ERROR. The error body's code is typed as a string and the codes are listed in each response's description, so a generated client will not reject a code it was not told about. Each code has its own page under error codes.
Official SDKs are being prepared but are not yet published on npm or PyPI. Until they are, generating from the spec is the supported way to get typed access.
TypeScript: openapi-typescript
Generate one .d.ts file of types (no runtime code):
npx openapi-typescript https://api.astronode.dev/v1/openapi.json -o astronode.d.ts
The output exports a paths interface keyed by URL and method. There are no operation IDs in the spec, so you address an operation by its path - which is also what appears in the docs and the error details:
panchang.ts - typed request body, success and error:
import type { paths } from "./astronode";
type Panchang = paths["/v1/panchang"]["post"];
type PanchangBody = Panchang["requestBody"]["content"]["application/json"];
type PanchangOk = Panchang["responses"][200]["content"]["application/json"];
type ApiError = Panchang["responses"][400]["content"]["application/json"];
const body: PanchangBody = { date: "2026-12-01", tz_offset_minutes: 330, lat: 19.076, lng: 72.8777 };
const res = await fetch("https://api.astronode.dev/v1/panchang", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ASTRONODE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
if (!res.ok) {
const { error } = (await res.json()) as ApiError;
throw new Error(`${res.status} ${error.code}: ${error.message}`);
}
const { data } = (await res.json()) as PanchangOk;
console.log(data.tithi.name, data.tithi.paksha, data.sunrise);Output (Node 24 runs the file directly; a wrong key gives the second line):
Ashtami Krishna 2026-12-01T01:25:17.000Z Error: 401 UNAUTHORIZED: Invalid API key
Misspell a field - tz_offset for tz_offset_minutes - and tsc stops you with TS2353: Object literal may only specify known properties, and 'tz_offset' does not exist in type '{ date: string; tz_offset_minutes: number; lat: number; lng: number; }'. The server would have returned 400 VALIDATION_ERROR for the same body, because request schemas are strict.
Other languages
Any generator that reads OpenAPI 3.1 can take the same URL; openapi-generator is the common multi-language choice (Python, Go, Kotlin, Swift and more). Because the spec has no operation IDs, generated method names are derived from paths - check them once and wrap the handful you use. Whichever client you build, call it from your server: the API key must never ship in a browser or mobile bundle.
You do not need a generator to use the spec. This Python standard-library script lists the documented responses for one operation:
import json
import urllib.request
spec = json.load(urllib.request.urlopen("https://api.astronode.dev/v1/openapi.json"))
op = spec["paths"]["/v1/dasha/yogini"]["post"]
for status, response in sorted(op["responses"].items()):
print(status, response["description"][:72])200 Default Response 400 `VALIDATION_ERROR` - the body, query string or path failed validation (` 401 `UNAUTHORIZED` - the `Authorization: Bearer` header is missing, malforme 403 `PLAN_REQUIRED` - this endpoint needs the Hobby plan or higher. `details 409 `IDEMPOTENCY_KEY_REUSED` - the `Idempotency-Key` was already used with a 429 `RATE_LIMITED` - the per-key, 60-second window is full; wait `Retry-Afte 500 `INTERNAL_ERROR` - unexpected server error. Safe to retry with backoff;
Keeping types current
- Regenerate in CI and commit the
.d.ts: a diff in review is how you notice a new field or endpoint. - New response fields are additions; your existing types keep compiling. The changelog lists contract changes.
- The envelope is the same everywhere -
{ request_id, data, interpretation, meta }on success and{ request_id, error }on failure; see the response envelope reference.
Questions
- Where is the AstroNode OpenAPI spec?
- At
https://api.astronode.dev/v1/openapi.json. It is OpenAPI 3.1 and needs no API key to download. - Does the spec include operation IDs?
- No. You address an operation by its path, and generators derive method names from paths, so check the generated names once and wrap the ones you use.