AstroWay/api v2.204.2 · vi
tất cả hệ thống hoạt động bình thường

Natal Chart API in TypeScript: SDK + React Example

Compute a natal chart in TypeScript with the AstroWay SDK - typed responses, a React component, and where it beats a local ephemeris library.

The AstroWay TypeScript SDK is generated from the OpenAPI spec, so request bodies and responses are fully typed - your IDE autocompletes the fields and the compiler catches mistakes before runtime. Here’s a natal chart, then the same call inside a React component.

Terminal window
npm install @astroway/sdk
# or: pnpm add @astroway/sdk

Get a key on the dashboard - 10,000 credits/month free, no card.

import { Astroway } from '@astroway/sdk';
const aw = new Astroway({ apiKey: process.env.ASTROWAY_API_KEY! });
const chart = await aw.chart.compute({
date: '1990-07-14',
time: '14:30:00',
timezoneOffset: 3,
latitude: 50.45,
longitude: 30.52,
});
// chart.planets is typed - not `any`
for (const p of chart.planets) {
console.log(`${p.name} ${p.longitude.toFixed(2)}° ${p.sign}`);
}

The { ok, data, error } envelope is unwrapped for you, so chart is the data. Need a raw response or an endpoint without a typed namespace yet? aw.client.POST('/chart', { body }) is the underlying typed fetch.

No extra dependency needed - call the SDK from an effect (or a server action / route handler if you don’t want the key in the browser):

import { useEffect, useState } from 'react';
import { Astroway } from '@astroway/sdk';
const aw = new Astroway({ apiKey: import.meta.env.VITE_ASTROWAY_KEY });
export function NatalChart({ birth }: { birth: {
date: string; time: string; timezoneOffset: number; latitude: number; longitude: number;
} }) {
const [planets, setPlanets] = useState<{ name: string; sign: string }[]>([]);
useEffect(() => {
aw.chart.compute(birth).then((c) => setPlanets(c.planets));
}, [birth]);
return (
<ul>
{planets.map((p) => <li key={p.name}>{p.name} in {p.sign}</li>)}
</ul>
);
}

In production, keep the API key server-side: call aw.chart.compute from a Next route handler or a small proxy and pass the result to the client. The SDK runs the same in Node, edge runtimes and the browser.

Mutating-style calls take an idempotency key so a retry can’t double-charge credits, and errors are a typed hierarchy:

import { RateLimitError, BadRequestError } from '@astroway/sdk';
try {
await aw.synastry.aspectGrid(body, { idempotencyKey: 'replay-abc' });
} catch (e) {
if (e instanceof RateLimitError) {/* back off */}
if (e instanceof BadRequestError) {/* show which field failed */}
}

A browser-only ephemeris library ships hundreds of kilobytes of WASM + data to every visitor. The SDK keeps the calculation server-side over a typed HTTP call, so your bundle stays small and you also get 761 other endpoints (synastry, transits, Human Design, AI interpretations) without adding dependencies.

MakSeong · AstroWay

Tôi làm AstroWay API: gói Swiss Ephemeris vào REST thuần và viết về những chi tiết nhàm chán nhưng thực sự quan trọng.

// xây dựng trên nền tảng này

Chính Swiss Ephemeris giống như trong Solar Fire - chỉ trong 4 dòng code.

Khóa API miễn phí không cần thẻ. 5.000 lượt gọi/tháng trước lần thanh toán đầu tiên.

Thêm từ blog tất cả bài viết →

Ephemeris 2026-07-19

Cách chúng tôi giữ độ chính xác dưới kiểm soát: CI vs swetest và NASA

Độ chính xác trong astro-API dễ bị suy giảm chỉ sau một lần refactor ephemeris. Chúng tôi phân tích bảo vệ: một lõi Swiss Ephemeris cho ứng dụng và API, hàng trăm snapshot đóng băng trên bản đồ chuẩn và việc tam giác mỗi PR so với swetest CGI, Kerykeion, Prokerala và catalogue of NASA eclipses.

Engineering 2026-07-15

Ba SDK chính thức: TypeScript, Python, PHP thay vì curl thô

HTTP thô hoạt động, nhưng client có kiểu dữ liệu tiết kiệm giờ: tự động hoàn thiện đường dẫn, kiểu yêu cầu và phản hồi, retry tích hợp cho 408/409/429/5xx và Stainless-style hệ thống lỗi. Xem xét ba SDK chính thức - @astroway/sdk (npm), astroway (PyPI), astroway/sdk (Packagist) - và cách chúng được tạo từ một OpenAPI contract.

Industry 2026-06-05

Free Astrology API: Which One Has the Best Free Tier in 2026?

A side-by-side of free tiers across the major astrology APIs - credits, request caps, card requirements - and how much you can actually build for free.