# TypeScript interfaces for every AstroNode endpoint

> No SDK yet, and no wish to run a generator for one call? Pick the endpoint you are integrating and copy a self-contained block of interfaces for its request and response. Every block is converted from the same OpenAPI spec the server validates requests with.

Source: https://astronode.dev/tools/endpoint-typescript-types · Updated: 2026-12-04

The interactive tool runs in the browser at https://astronode.dev/tools/endpoint-typescript-types; this file is its explanation.

## What you get for each endpoint

- `…Request` - the JSON body, with required fields non-optional and each field's pattern, range or default as a JSDoc comment.
- `…PathParams` and `…Query` - for GET routes such as `/v1/horoscope/daily/:sign`, including the enum of signs.
- `…Data` - the payload inside `data` (`…Job` for the three asynchronous report routes, whose 202 is a job handle).
- `…Response` - the full body: `request_id`, `data`, `interpretation` and `meta`. The two chat-service routes that answer at the top level get only this one.

Names come from the path: `POST /v1/dasha/vimshottari` gives `DashaVimshottariRequest`, `DashaVimshottariData`, `DashaVimshottariResponse`. The envelope is described in the [response envelope reference](https://astronode.dev/reference/response-envelope).

## How the conversion works

A build script reads `specs/api.openapi.json` and `specs/chat.openapi.json` and converts each schema node: `anyOf` becomes a union (so the panchang's `sunrise` is `string | null`), `enum` a union of literals (the dasha `levels` is `1 | 2 | 3 | 4 | 5`), `integer` a `number` marked `integer`, and an object keyed by arbitrary names a `Record` or index signature. Nothing is cut short: unions keep every member and nesting goes all the way down.

The output is committed with the site and a CI check fails when it no longer matches the spec, so the page cannot drift from the API.

## Declared versus recorded response fields

For **85 of the 122** endpoints the spec declares `data` without a schema, because those routes return computed results whose shape is checked at runtime rather than declared. For them the spec carries a shape **recorded from one real response** to the endpoint's sample request. The generated `…Data` for those endpoints says so in its comment, every field is optional, and each array shows the element shape that response contained. Request types are always the declared, validated contract. The [response JSON explorer](https://astronode.dev/tools/response-json-explorer) uses the same flag.

## Common mistakes

- **Treating recorded fields as guaranteed.** A field present in the sample may be absent for another chart (an empty list, a missing optional block). Narrow before you use it.
- **Typing the whole body as `…Data`.** Public-API results sit under `data`; errors use `{ request_id, error: { code, message, details } }` instead.
- **Assuming integers are checked by TypeScript.** `number` accepts 330.5 for `tz_offset_minutes`; the server rejects it with 400. The JSDoc shows the range.
- **Regenerating by hand.** For a whole typed client use `openapi-typescript` on the live spec - see the [typed client guide](https://astronode.dev/guides/openapi-typed-client).

## FAQ

**How is this different from running openapi-typescript?**

openapi-typescript produces one `paths` interface for the whole API, addressed by URL. This page gives named interfaces for a single endpoint, ready to paste into a project that calls one or two routes.

**Are the chat API endpoints included?**

Yes, from the chat service's own spec. The streaming route has no JSON body, so it gets only a request type and a note.

**What about the request headers?**

They are the same for every endpoint - `Authorization: Bearer <key>` and, for POST, `Content-Type: application/json` - so they are not repeated per endpoint.

## Related endpoints

- [`POST /v1/charts/birth`](https://astronode.dev/capabilities/vedic/charts-birth) - Birth Chart (Kundli) API
- [`POST /v1/panchang`](https://astronode.dev/capabilities/vedic/panchang) - Panchang API
- [`POST /v1/dasha/vimshottari`](https://astronode.dev/capabilities/vedic/dasha-vimshottari) - Vimshottari Dasha API
- [`POST /v1/chat/respond`](https://astronode.dev/capabilities/chat/chat-respond) - AI Astrologer Chat API
