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

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 AstroWaypip 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 — the same Swiss Ephemeris engine (compiled to WebAssembly server side), reached over HTTP. Nothing to compile or ship; you trade a network round-trip for zero install and 722 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.

AstroWay team

Đội ngũ kỹ thuật AstroWay API. Chúng tôi đóng gói Swiss Ephemeris thành REST sạch và viết về những chi tiết nhàm chán nhưng 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-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.

Engineering 2026-05-21

Chiêm tinh Vedic thông qua API: từ Parasara đến Lal Kitab trong 354 endpoint

AstroWay hiện cung cấp phạm vi Vedic rộng nhất trong số các API thương mại: 10 hệ thống dasha, 16 varga, Panchang, Lal Kitab đầy đủ + KP + Jaimini. Cách nó hoạt động và khi nào chọn kỹ thuật nào.