AstroWay/api v2.325.2 · fr
tous les systèmes sont opérationnels

Natal Chart API in Python: 3 Examples with the AstroWay SDK

How to compute a natal chart in Python via API - install, first request, transits and synastry - with working code and how it compares to pyswisseph and kerykeion.

If you’re building astrology features in Python, you have two paths: bundle an ephemeris library and do the math locally, or call an API that already does it. This post takes the API route with AstroWay - pip install, a first natal chart, then transits and synastry - and shows where each approach makes sense.

Terminal window
pip install astroway
# or: uv add astroway / poetry add astroway

Grab a key at the dashboard - 10,000 credits/month free, no card. A full natal chart costs 20 credits, so the free tier covers roughly 500 charts a month.

The SDK exposes typed namespaces generated from the OpenAPI spec. chart.compute takes a BirthData model (or a plain dict) and returns the unwrapped result - no { ok, data } envelope to peel:

from astroway import Astroway, BirthData
aw = Astroway(api_key="aw_live_...")
chart = aw.chart.compute(BirthData(
date="1990-07-14",
time="14:30:00",
timezone_offset=3,
latitude=50.45,
longitude=30.52,
))
for planet in chart.planets:
print(f"{planet.name:10} {planet.longitude:.2f}° in {planet.sign}")

The API does not geocode - pass the latitude/longitude and the UTC offset for the birth moment yourself (a one-line lookup with geopy + timezonefinder if you only have a city name).

2. Transits for “what’s happening now”

Section titled “2. Transits for “what’s happening now””

Transit-based features (daily insights, “Saturn is squaring your Sun”) need a second date. transits.compute takes the birth data plus a target_date:

from astroway import TransitsRequest
transits = aw.transits.compute(TransitsRequest(
date="1990-07-14", time="14:30:00", timezone_offset=3,
latitude=50.45, longitude=30.52,
target_date="2027-01-01",
))
for hit in transits.aspects:
print(f"{hit.transiting} {hit.aspect} natal {hit.natal} (orb {hit.orb:.1f}°)")

This is the real difference between a calculation API and a “horoscope text” API: you get the actual aspects, not a paragraph generated by an LLM.

synastry.compute takes two charts and returns the inter-aspect grid plus a compatibility score:

from astroway import SynastryRequest
result = aw.synastry.compute(SynastryRequest(
chart1=BirthData(date="1990-07-14", time="14:30:00", timezone_offset=3, latitude=50.45, longitude=30.52),
chart2=BirthData(date="1992-03-22", time="09:15:00", timezone_offset=2, latitude=48.85, longitude=2.35),
))
print(f"Compatibility: {result.score}/100")

The async client has the same surface. Retries on 429/5xx with exponential backoff are built in, and errors are a typed hierarchy:

import asyncio
from astroway import AsyncAstroway
from astroway import RateLimitError, BadRequestError
async def main():
async with AsyncAstroway(api_key="aw_live_...") as aw:
try:
chart = await aw.chart.compute({
"date": "1990-07-14", "time": "14:30:00",
"timezoneOffset": 3, "latitude": 50.45, "longitude": 30.52,
})
except RateLimitError:
... # back off and retry later
except BadRequestError as e:
print(e) # which field failed validation
asyncio.run(main())

(Note: the BirthData model uses timezone_offset; a raw dict uses the JSON field name timezoneOffset. Both work.)

  • pyswisseph: Python bindings for the Swiss Ephemeris C library. Maximum control, but you compile a C extension, ship the ephemeris data files, and implement house systems, aspects and chart logic yourself.
  • kerykeion: a higher-level library on top of pyswisseph. Less boilerplate, but still a local dependency you install, version and deploy.
  • AstroWay: arc-second positions verified against NASA JPL Horizons, computed on our servers and reached over HTTP. Nothing to compile or ship; you trade a network round-trip for zero install and 865 endpoints beyond the natal chart (synastry, transits, Vedic, Human Design, AI interpretations).

Rule of thumb: a CLI tool or a notebook that runs offline → a local library. A web app, a serverless function, or anything where you don’t want to manage ephemeris files and house-system code → the API.

MakSeong · AstroWay

Je fais l'API AstroWay : j'enveloppe des calculs astrologiques à la seconde d'arc dans du REST pur et j'écris sur les détails ennuyeux qui sont en fait importants.

// construis avec ça

Des positions à la seconde d'arc en 4 lignes de code.

Clé gratuite sans carte. 5 000 appels par mois avant le premier paiement.

Plus d'articles du blog voir tous les articles →

Ephemeris 2026-07-19

Comment nous gardons la précision sous contrôle : la CI contre swetest et la NASA

Dans une API d'astrologie, la précision se dégrade facilement après un seul refactoring des éphémérides. Voici notre protection : un seul noyau Swiss Ephemeris pour l'application et l'API, des centaines de snapshots figés sur des thèmes de référence et la triangulation de chaque PR contre swetest CGI, Kerykeion, Prokerala et le catalogue d'éclipses de la NASA.

Engineering 2026-07-15

Trois SDK officiels : TypeScript, Python, PHP au lieu de curl brut

Le HTTP brut fonctionne, mais un client typé fait gagner des heures : autocomplétion des chemins, types de requête et de réponse, retry intégré sur 408/409/429/5xx et hiérarchie d'erreurs à la Stainless. Tour d'horizon des trois SDK officiels, @astroway/sdk (npm), astroway (PyPI), astroway/sdk (Packagist), et de la manière dont ils sont générés à partir d'un même contrat OpenAPI.

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.