Skip to main content

astroway

Official Python SDK for the AstroWay API: natal charts, synastry, transits, Vedic dashas, Tarot, Numerology, Human Design, AI horoscopes. Sync + async, type-hinted, retry-aware.

PyPI version Python versions license: MIT

700+ endpoints. Synchronous and asynchronous clients with the same surface. Built-in retry on 408/409/429/5xx with exponential backoff. Stainless-style error hierarchy (AuthenticationError / RateLimitError / BadRequestError / …). Just httpx + pydantic under the hood.


Install

pip install astroway
# or with uv
uv add astroway
# or with poetry
poetry add astroway

Get an API key at https://api.astroway.info/dashboard/sign-up: 10 000 credits/month free, no card required. Each endpoint costs 5–500 credits depending on what it computes (pricing).

Requires Python 3.9+.


Quick start

Synchronous

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,
    house_system="P",
))

SIGNS = ["Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo",
         "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces"]

asc = chart["houses"]["ascendant"]                            # 212.0953
print(f"ASC: {SIGNS[int(asc // 30)]} {asc % 30:.2f}°")        # ASC: Scorpio 2.10°
print(f"Sun: {chart['planets'][0]['longitude']:.2f}°")        # Sun: 111.77°

/chart returns positions, not labels: houses["ascendant"] and every planets[i]["longitude"] are ecliptic longitudes in degrees, so the sign is longitude // 30 into the list above and the degree within it is longitude % 30.

Asynchronous

import asyncio
from astroway import AsyncAstroway

async def main() -> None:
    async with AsyncAstroway(api_key="aw_live_...") as aw:
        chart = await aw.chart.compute({
            "date": "1990-07-14",
            "time": "14:30:00",
            "timezoneOffset": 3,
            "latitude": 50.45,
            "longitude": 30.52,
        })
        print(chart["houses"]["ascendant"])

asyncio.run(main())

The SDK exposes 103 typed namespaces / 623 methods auto-generated from the OpenAPI spec: aw.synastry.aspect_grid({...}), aw.bazi.day_master({...}), aw.vedic.dashas_vimshottari_maha({...}), etc. The { ok, data, error } envelope is unwrapped for you.

Top-4 categories (chart, synastry, transits, vedic dashas) ship Pydantic v2 request models for IDE autocomplete + validation: BirthData, SynastryRequest, TransitsRequest, VedicDashaRequest. Pass either a model or a dict, both work everywhere.

Sync and async clients share an identical surface: both expose the same namespaces, plus low-level aw.request(method, path, body=…) / aw.post(path, body=…) escape hatches.


Common workflows

Synastry

from astroway import BirthData, 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"Score: {result['compatibility']['score']}/100 ({result['compatibility']['label']})")

Transits to natal

from astroway import TransitsRequest

transits = aw.transits.compute(TransitsRequest(
    date="1990-07-14", time="14:30:00", timezone="Europe/Kyiv", latitude=50.45, longitude=30.52,
    transit_date="2027-01-01",
))

Vedic Vimshottari Mahadasha

from astroway import VedicDashaRequest

dasha = aw.vedic.dashas_vimshottari_maha(VedicDashaRequest(
    date="1985-07-22", time="06:45:00", timezone_offset=5.5,
    latitude=19.07, longitude=72.87,
))

Tarot daily card

card = aw.tarot.rider_waite_daily({"seed": 42})

Human Design

hd = aw.human_design.compute({
    "date": "1990-07-14", "time": "14:30:00", "timezoneOffset": 3, "latitude": 50.45, "longitude": 30.52,
})
print(f"{hd['type']} - {hd['strategy']} - {hd['authority']}")

Natal interpretation texts

Pre-written interpretation snippets for planet-in-sign, planet-in-house and aspect placements, no AI at request time, one ordinary call regardless of how many keys you ask for:

result = aw.natal_texts(["sun.aries", "moon.h4", "sun_moon.trine"], lang="uk")
print(result.texts["sun.aries"].body)
print(result.missing)  # keys with no text in "uk"; no fallback to another language

Chart image (SVG)

chart = aw.chart.compute(BirthData(date="1990-07-14", time="14:30:00", timezone_offset=3, latitude=50.45, longitude=30.52))
wheel = aw.render.wheel_western({"chart": chart, "options": {"theme": "css"}})   # 1 credit: draws the chart you hold
grid = aw.render.aspect_grid({"chart": chart})
bi = aw.render.bi_wheel({"natal": {"chart": chart}, "outer": {"chart": partner_chart}, "options": {"crossAspects": True}})
print(wheel["svg"][:60])

theme: "css" paints colours as CSS variables (--aw-ring, --aw-fg...) and adds stable aw-* classes, so an SVG inlined into your page takes its colours. The four Western wheels take labels (asc, dsc, mc, ic, title, desc and per-body names under bodies) for your own language; crossAspects on the bi-wheel draws the aspects between the two charts. {"chart": ...} is a /chart response passed as is, accepted by wheel_western, aspect_grid and bi_wheel. From birth data instead, aw.render.wheel_western({**birth, "options": {...}}) computes the chart too (10 credits). The options are passed through as a dict, so any value the API accepts works here. Docs: https://api.astroway.info/en/products/svg-charts/

Key and balance

info = aw.auth.keys.me()  # free, no credits
print(info["plan"], info["credits_remaining"], info["period_end"])

An unmetered key returns null credits and unlimited: True.

White-label PDF report

/reports/* endpoints accept an inline whitelabel object (the BrandingObject schema) to brand the generated PDF with your own logo, colours, and footer:

report = aw.reports.natal({
    "chart": {
        "date": "1990-07-14", "time": "14:30:00",
        "timezoneOffset": 3, "latitude": 50.45, "longitude": 30.52,
    },
    "whitelabel": {
        "companyName": "Acme Astrology",
        "reportName": "Your Natal Blueprint",
        "themeColor": "#5b21b6",
        "footerText": "© Acme Astrology",
    },
})
print(report["url"])  # signed PDF URL

Pass "whitelabel": True instead of an object to pull branding from your account's stored config (requires a wpUserId-bound key).

Streaming

Two endpoints answer Server-Sent Events rather than JSON, and their namespace methods return a stream:

for chunk in aw.mcp.streaming({"message": "What is a stellium?"}):
    if chunk.type == "text_delta":
        print(chunk.text, end="", flush=True)
    elif chunk.type == "done":
        break

The async client returns the async variant, walked with async for. Any other SSE-capable path goes through aw.stream_sse(path, body=...), which yields the same chunks.


Error handling

The SDK raises typed subclasses of ApiError. Catch order matters, most specific first:

from astroway import (
    Astroway, ApiError,
    AuthenticationError, RateLimitError, BadRequestError,
)

try:
    aw.post("/chart", body=body)
except RateLimitError as e:
    time.sleep(e.retry_after_seconds or 60)
    # retry once...
except AuthenticationError:
    raise RuntimeError("Rotate your AstroWay API key")
except BadRequestError as e:
    print("Validation failed:", e.body)
except ApiError as e:
    print(f"API error {e.status} ({e.code}): {e!s} [request_id={e.request_id}]")

Full hierarchy:

  • ApiError (base)
    • APIConnectionError
      • APITimeoutError
    • BadRequestError (400)
    • AuthenticationError (401)
    • PermissionDeniedError (403)
    • NotFoundError (404)
    • UnprocessableEntityError (422)
    • RateLimitError (429), carries retry_after_seconds
    • InternalServerError (5xx)

The 400 you are most likely to hit first

Chart bodies take latitude, longitude and timezone_offset (timezoneOffset over the wire). The short spellings lat, lon, lng, long, tz and timezone are refused with a BadRequestError whose e.code is INVALID_FIELD, and e.body["error"]["details"] names every offending field at once as {"path", "expected", "message"}. They are not accepted and not deprecated: they were never in the spec, and before the API started refusing them they were silently ignored, which charted 0°N 0°E at UTC under a 200. Details: https://api.astroway.info/en/errors/#invalid_field.


Configuration

aw = Astroway(
    api_key="aw_live_...",                  # required
    base_url="https://api.astroway.info/v1", # override for staging / self-hosted
    auth_scheme="header",                    # "header" (X-Api-Key, default) or "bearer" (Authorization: Bearer)
    timeout=30.0,                            # per-request timeout in seconds
    retry={
        "max_retries": 2,                    # total attempts = 1 + max_retries
        "base_delay_ms": 250,
        "max_delay_ms": 30_000,
        "retryable_statuses": frozenset({408, 409, 429, 500, 502, 503, 504}),
    },
    default_headers={"X-Trace-Id": "..."},
)

The default retry honors Retry-After (seconds or HTTP-date) on 429 responses.

Set retry={"max_retries": 0} to disable retries entirely.


Authentication

Two equivalent auth schemes, pick whichever your stack prefers:

  • Header (default): X-Api-Key: aw_live_..., the same convention as curl/Postman examples.
  • Bearer: Authorization: Bearer aw_live_..., the same convention as Stripe/OpenAI/Anthropic SDKs.

Set via auth_scheme="bearer" in the constructor.


Privacy

The SDK does not phone home. There is no telemetry, no analytics, no usage reporting. The only network traffic the SDK originates is the AstroWay API calls you ask it to make.

Outgoing requests carry two identifying headers so the AstroWay backend can distinguish SDK traffic from raw HTTP traffic in its own logs:

  • User-Agent: astroway-sdk-python/<version> (Python/<py-version>; <platform>)
  • X-Astroway-Channel: sdk-py

Neither carries a session ID, machine fingerprint, or anything personal.


Stability

Since 1.0.0 (2026-05-11) this package follows strict SemVer:

  • Public names in astroway.__all__ stable inside 1.x. Removing or narrowing requires a 2.0.0 major bump with deprecation period.
  • Method signatures stable inside 1.x. Adding a new keyword-only parameter (with default) is non-breaking; reordering or renaming is breaking.
  • Body shape stable inside 1.minor. Tightening (constraints, enum) ships in patches; new required keys require a minor bump.
  • API version vs SDK version are independent. SDK 1.x follows its own semver; the API itself sits at /v1/.
  • Python 3.10+ required since 1.0.0. Need 3.9? Stay on 0.x (will receive critical security patches).

Migration from 0.1.0a1 … 0.1.0rc1 to 0.1.0

0.1.0 freezes the public surface. No breaking changes vs 0.1.0rc1: every export, namespace, error class, and option added across alphas / betas / RCs ships unchanged. The freeze means future 0.1.x patches will not narrow types or remove names; that level of change requires a 0.2.0 minor bump.

Coming from Action
0.1.0a1 (manual aw.post('/chart', body=...)) Switch to typed namespaces: aw.chart.compute(body), aw.synastry.aspect_grid(body), etc. The escape hatch (aw.request(...)) still works.
0.1.0a2 … a3 (no idempotency / errors) Pick up automatic Idempotency-Key on POSTs, error.request_id / error.credits_remaining getters, Pydantic models for top categories.
0.1.0a4 … a6 (no helpers) from astroway.helpers import BirthDateTime for from_city() / from_coordinates().
0.1.0b1 … b3 (no streaming / cache / mock) for chunk in aw.charts.compute(...).stream(), Astroway(cache=MemoryCache()), from astroway.testing import MockAstroway.
0.1.0rc1 (no bring-your-own httpx) Optional: pass http_client=httpx.Client(...), limits=httpx.Limits(...), or transport='aiohttp' (with pip install astroway[aiohttp]).

A type-stability test suite (tests/test_types.py) inspects constructor signatures, error subclass tree, dataclass fields, and Literal unions: any future PR that breaks the public surface fails CI before reaching PyPI.



License

MIT, see LICENSE.

Metadata

Release files for astroway 1.12.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for astroway 1.12.0
File Size Uploaded Provenance Actions
astroway-1.12.0.tar.gz 726.0 kB With provenance Details for astroway-1.12.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for astroway 1.12.0
File Interpreter ABI Platform Actions
astroway-1.12.0-py3-none-any.whl Python 3 none any Details for astroway-1.12.0-py3-none-any.whl

Total release size: 817.3 kB

Release files / astroway-1.12.0.tar.gz

Download URL astroway-1.12.0.tar.gz
Size 726.0 kB
Tags Source
SHA-256 checksum
How to use checksums
60c085c93c88caafcba88bf80c5bac2dea03d4b959e1d757418c5ed1db977e8c
BLAKE2b-256 checksum
How to use checksums
f7cd1d66a60cb44a511ec22c8f89536bfd4d23b44c658283da69b9f06ae5049d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Release files / astroway-1.12.0-py3-none-any.whl

Download URL astroway-1.12.0-py3-none-any.whl
Size 91.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1b9e2cfa4b45b1649b54e2cd0cb007f53b8b0edcbc17434b32463a6a9ff7ff5c
BLAKE2b-256 checksum
How to use checksums
9e71fd4baba0915ed9df52a1f68fc910c43a3cd79b9c6e0ef0962679879c3c5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Security for astroway 1.12.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for astroway-1.12.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page