← Developer tools

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.

Free · runs in your browser · no API key needed · updated

typescript
// POST /v1/charts/birth
// Compute the D1 (Lagna) birth chart.
// Generated from specs/api.openapi.json by https://www.astronode.dev/tools/endpoint-typescript-types
/** JSON request body. */
export interface ChartsBirthRequest {
  /** pattern ^\d{4}-\d{2}-\d{2}$ */
  date: string;
  /** pattern ^\d{2}:\d{2}(:\d{2})?$ */
  time: string;
  /** Offset from UTC in minutes (e.g., 330 for IST) · integer · range -840..840 */
  tz_offset_minutes: number;
  /** range -90..90 */
  lat: number;
  /** range -180..180 */
  lng: number;
  interpretation?: {
    /** default "en" */
    language?: "en" | "hi";
    /** default "standard" */
    verbosity?: "short" | "standard" | "detailed";
  };
}

/** `data` of a 200 response. */
export interface ChartsBirthData {
  ascendant: {
    sign: string;
    degree: number;
  };
  planets: {
    name: string;
    sign: string;
    /** integer · range 1..12 */
    house: number;
    degree_in_sign: number;
    nakshatra: string;
    /** integer · range 1..4 */
    nakshatra_pada: number;
    retrograde: boolean;
  }[];
  meta: {
    ayanamsa: string;
    house_system: string;
    engine_version: string;
  };
}

/** The full 200 body: the envelope around `data`. */
export interface ChartsBirthResponse {
  request_id: string;
  data: ChartsBirthData;
  interpretation: {
    type: "chart_summary";
    version: string;
    language: "en" | "hi";
    verbosity: "short" | "standard" | "detailed";
    disclaimer: string;
    summary: string;
    sections: {
      personality: string;
      strengths: string[];
      growth_areas: string[];
      key_planetary_influences: {
        planet: string;
        text: string;
      }[];
    };
  } | null;
  meta: {
    engine_version: string;
    computed_at: string;
  };
}

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.

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 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.

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.