React Native astrology API quickstart

Through your backend, never direct.

The important part of a React Native integration is what you do not do: the API key cannot live in the app. Anything shipped in a bundle can be extracted from it, so the app talks to your server and your server holds the key.

No official React Native SDK, and you would not want the API key in one. The app calls your own endpoint; your server calls AstroNode.

Step 1

Your server holds the key

One endpoint on your backend, which validates the input and forwards it. This is the only place the key appears.

ts
// server: POST /api/chart
export async function POST(req: Request) {
  const birth = await req.json();
  // Validate before forwarding - this endpoint is reachable by anyone.
  const res = await fetch("https://api.astronode.dev/v1/charts/birth", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.ASTRONODE_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify(birth),
  });
  const json = await res.json();
  if (!res.ok) return Response.json(json.error, { status: res.status });
  return Response.json(json.data);
}

Step 2

The app calls your server

No key, no secret, nothing to extract from the bundle.

tsx
const YOUR_API = "https://your-app.example.com";

export async function fetchChart(birth: {
  date: string;
  time: string;
  tz_offset_minutes: number;
  lat: number;
  lng: number;
}) {
  const res = await fetch(`${YOUR_API}/api/chart`, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify(birth),
  });
  if (!res.ok) throw new Error((await res.json()).message ?? "Chart failed");
  return res.json();
}

Step 3

Getting the birth coordinates

The API takes latitude, longitude and a UTC offset - not a place name. On device, resolve the birthplace once with whichever geocoder you already use and store the coordinates with the profile.

tsx
// Store what the API needs, not what the user typed:
type BirthProfile = {
  date: string;               // "1993-07-04"
  time: string;               // "09:27:11"
  tz_offset_minutes: number;  // 330 for IST
  lat: number;                // 31.7473
  lng: number;                // 77.7754
  placeLabel: string;         // display only - never sent
};

Next

Where to go from here

The call above is one of 110 endpoints. They all take the same bearer token and return the same envelope, so the second one is a path change. Each endpoint page carries its request fields and constraints.

Free tier covers 1,000 requests / month. No card, and test keys work on every endpoint.

Other languages

Same call, different stack