AstroWay/api v2.296.1 · blog
all systems operational

Astrology API Quick Start: TypeScript & Python in 5 Minutes

Install the SDK, get an API key, make your first natal chart request. 5 minutes, working code in TypeScript and Python.

🕓 Recorded 2026-04-14, updated 2026-05-09. TS / Python / PHP SDKs are now live on public registries - @astroway/sdk (npm), astroway (PyPI), astroway/sdk (Packagist). Details in changelog.

You want to calculate a natal chart from code. Here’s the fastest path - under 5 minutes from nothing to working JSON.

Register at api.astroway.info/dashboard/sign-up. Free plan: 10,000 credits/month. No credit card.

In the dashboard, click “Create key” → “Production” → copy it. Keys look like aw_live_aB3xY7pQ9rN2mK4jH8vC5tL6wZ1fD0eR.

Tip: There are also aw_test_ sandbox keys that don’t consume credits. Use them for development.

Terminal window
npm install @astroway/sdk
Terminal window
pip install astroway

Both SDKs cover all 777 endpoints with typed requests and responses.

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, // UTC+3 for Kyiv summer
latitude: 50.4501,
longitude: 30.5234,
houseSystem: 'P', // Placidus
});
const SIGNS = ['Aries', 'Taurus', 'Gemini', 'Cancer', 'Leo', 'Virgo',
'Libra', 'Scorpio', 'Sagittarius', 'Capricorn', 'Aquarius', 'Pisces'];
const sun = chart.planets.find((p) => p.name === 'Sun')!;
console.log(`Sun: ${SIGNS[Math.floor(sun.longitude / 30)]} at ${sun.longitude.toFixed(2)}°`);
console.log(`ASC: ${chart.houses.ascendant.toFixed(2)}°`);
console.log(`Aspects: ${chart.aspects.length}`);

Run it:

Terminal window
ASTROWAY_API_KEY=aw_live_... npx tsx chart.ts

The file uses top-level await, so your package.json needs "type": "module". Without it tsx fails with Top-level await is currently not supported with the "cjs" output format.

from astroway import Astroway, BirthData
aw = Astroway(api_key="aw_live_your_key_here")
chart = aw.chart.compute(BirthData(
date="1990-07-14",
time="14:30:00",
timezone_offset=3,
latitude=50.4501,
longitude=30.5234,
house_system="P",
))
SIGNS = ["Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo",
"Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces"]
sun = next(p for p in chart["planets"] if p["name"] == "Sun")
print(f"Sun: {SIGNS[int(sun['longitude'] // 30)]} at {sun['longitude']:.2f}°")
print(f"ASC: {chart['houses']['ascendant']:.2f}°")
print(f"Aspects: {len(chart['aspects'])}")

Run it:

Terminal window
ASTROWAY_API_KEY=aw_live_... python3 chart.py

You get back a JSON object with four main parts:

Array of 13 objects. name carries the Swiss Ephemeris label for the body: Sun, Moon, Mercury, Venus, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto, true Node (the North Node), mean Apogee (Lilith), Chiron.

{
"id": 0,
"name": "Sun",
"longitude": 354.702, // ecliptic longitude in degrees
"latitude": -0.00016,
"distance": 0.9945, // in astronomical units
"speedLong": 0.9971, // degrees per day (negative = retrograde)
"speedLat": 0.00003,
"speedDist": 0.00019,
"isRetrograde": false,
"declination": -1.4159,
"rightAscension": 355.437
}

Sign and house are not returned here: derive the sign as Math.floor(longitude / 30), and the house from the cusps in houses.

House cusps (12 of them), plus ascendant and MC:

{
"system": "P",
"cusps": [118.18, 138.27, ...], // 12 values
"ascendant": 118.18,
"mc": 12.708,
"armc": 11.69,
"vertex": 253.97,
"equatorialAsc": 100.75,
"coAscWK": 81.13,
"coAscMunkasey": 123.7,
"polarAsc": 261.13
}

Array of aspects between planets:

{
"planet1": "Sun",
"planet2": "Mercury",
"planet1Id": 0,
"planet2Id": 2,
"type": { // an object, not a string
"name": "Conjunction",
"i18nKey": "aspect_conjunction",
"angle": 0,
"orb": 12,
"symbol": "☌",
"isMajor": true,
"color": "#660480"
},
"exactAngle": 3.365,
"orb": 3.365, // deviation from exact in degrees
"isApplying": true
}

"diurnal" (Sun above horizon at birth) or "nocturnal" (below). Used in classical astrology.

What to try next:

Synastry: compatibility between two people:

const synastry = await client.synastry({
chart1: { date: '1990-07-14', time: '14:30:00', timezoneOffset: 3, latitude: 50.45, longitude: 30.52 },
chart2: { date: '1992-03-22', time: '09:15:00', timezoneOffset: 2, latitude: 48.85, longitude: 2.35 },
});
console.log(`Compatibility score: ${synastry.compatibility.score}/100`);

Current transits on a natal chart:

const transits = await client.transits({
// birth data
date: '1990-07-14', time: '14:30:00', timezoneOffset: 3,
latitude: 50.4501, longitude: 30.5234,
// transit date
transitDate: '2026-04-14',
});

Daily horoscope generated from real transits:

const horoscope = await client.horoscopeDaily({
date: '1990-07-14', time: '14:30:00', timezoneOffset: 3,
latitude: 50.4501, longitude: 30.5234,
});
console.log(horoscope.text);

Full Human Design chart:

const hd = await client.humanDesign({
date: '1990-07-14', time: '14:30:00', timezoneOffset: 3,
latitude: 50.4501, longitude: 30.5234,
});
console.log(`${hd.type} - ${hd.strategy} - Profile ${hd.profile}`);
  • Natal chart (/chart): 20 credits
  • Synastry: 50 credits
  • Transits: 50 credits
  • Daily horoscope: 20 credits
  • Human Design: 50 credits

Free plan: 10,000 credits/month = 500 natal charts, or 200 synastries, or mixed workload.

Every response includes credit headers:

X-Credits-Used: 20
X-Credits-Remaining: 4980
X-Credits-Reset: 2026-05-01T00:00:00Z

When credits run out you get 402 Payment Required. When rate limit hits (Free: 10 req/min), 429 Too Many Requests with Retry-After header.

SDK throws typed errors you can catch:

import { QuotaExceededError, RateLimitError } from '@astroway/sdk';
try {
const chart = await aw.chart.compute(birth);
} catch (err) {
if (err instanceof QuotaExceededError) {
console.log('Upgrade plan or wait for reset');
} else if (err instanceof RateLimitError) {
console.log(`Retry in ${err.retryAfterSeconds ?? 60} seconds`);
} else {
throw err;
}
}

Catch order runs from specific to general: they all extend ApiError, so testing for that first swallows the rest.

You now have:

  • A working API key
  • SDK installed
  • First natal chart
  • Enough patterns to add synastry, transits, horoscopes

Next reading:

MakSeong · AstroWay

I build the AstroWay API: Swiss Ephemeris on a clean REST surface, and I write about the dull parts that turn out to matter.

// build with this

Same Swiss Ephemeris as Solar Fire - but in 4 lines of code.

Free key, no card. 5,000 calls/month before you pay anything.

More from the blog view all posts →

Engineering 2026-06-05

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.

Ephemeris 2026-06-05

How Accurate Is the Swiss Ephemeris? Verified Benchmarks

Swiss Ephemeris accuracy in numbers - planetary positions under 0.1 arcsecond, exact house cusps, eclipses within a minute - and how AstroWay verifies it.

Ephemeris 2026-06-05

Swiss Ephemeris: REST API vs pyswisseph (When to Use Which)

pyswisseph vs a REST API for Swiss Ephemeris calculations - C dependencies, data files, licensing and deployment compared, with a decision guide.