Skip to main content

freeastroapi

CI

Official Python client for FreeAstroAPI, with sync and async transports and typed methods for every public endpoint.

Install

pip install freeastroapi
# or
uv add freeastroapi

Quick start

import os

from freeastroapi import FreeAstro


with FreeAstro(api_key=os.environ["FREEASTRO_API_KEY"]) as client:
    cities = client.geo.search("Paris", limit=3)
    print(cities.results[0].timezone)

Async usage exposes the same resources:

import os

from freeastroapi import AsyncFreeAstro


async with AsyncFreeAstro(api_key=os.environ["FREEASTRO_API_KEY"]) as client:
    cities = await client.geo.search("Paris", limit=3)

Resources

Every public operation in the FreeAstroAPI OpenAPI document has a typed method on both clients. Resources follow the API paths:

from freeastroapi import FreeAstro, schemas

with FreeAstro(api_key="YOUR_API_KEY") as client:
    # POST /api/v1/natal/calculate?include_minor=true
    chart = client.natal.calculate(
        {"year": 1990, "month": 6, "day": 15, "hour": 14, "minute": 30, "city": "Paris"},
        include_minor=True,
    )

    # POST /api/v2/vedic/panchang
    request: schemas.PanchangRequestV2 = {"year": 2026, "month": 1, "day": 14, "hour": 6, "minute": 0, "city": "Delhi"}
    panchang = client.vedic.panchang(request)

    # POST /api/v1/western/progressions/secondary/exact-aspects
    hits = client.western.progressions.secondary_exact_aspects(progressions_request)

    # GET /api/v1/chinese/calendar/{date}
    day = client.chinese.calendar("2026-02-17", lang="en")

    # GET /api/v3/horoscope/daily/sign
    horoscope = client.horoscope.daily.sign(sign="aries")

Path parameters are positional, the JSON body (when there is one) comes next, and query parameters are keyword-only. Every method also takes options=RequestOptions(...).

When an operation exists in several API versions, the plain method name calls the latest version and older versions carry a suffix: client.vedic.chart calls /api/v2/vedic/chart and client.vedic.chart_v1 calls /api/v1/vedic/chart; client.horoscope.daily.sign_v1 / sign_v2 reach the older daily horoscopes.

Resource groups: ai, chinese, ephemeris, geo, horoscope, moon, natal, numerology, sky_events, space, transits, vedic, and western (with astrocartography, directions, electional, natal, progressions, signs, transits and more). freeastroapi.OPERATIONS lists every operation with its client method.

Types

Request bodies and responses are typed with TypedDicts generated from the spec's component schemas, in freeastroapi.schemas. They are plain dictionaries at runtime: responses are returned as parsed JSON without validation, so additive API fields never break your code. Where the spec does not describe a response, the method returns Any.

Chart render endpoints (client.vedic.kp_render, client.vedic.visual.chart) return SVG as text; use client.request_raw(...) for PNG output.

v0.1 methods

client.geo.search, client.moon.phase, client.moon.month, client.sky_events.list and client.western.signs.* keep their v0.1 signatures and return Pydantic v2 models.

Use client.request(...) for any other endpoint.

Western sign example

from freeastroapi import FreeAstro, RequestOptions, WesternSignRequest

birth = WesternSignRequest(
    year=1990,
    month=6,
    day=15,
    city="Paris",
)

with FreeAstro(api_key="YOUR_API_KEY") as client:
    sun = client.western.signs.sun(
        birth,
        options=RequestOptions(idempotency_key="stable-logical-request-key"),
    )

GET, HEAD, and OPTIONS requests retry transient network failures and HTTP 408, 429, 500, 502, 503, and 504 responses by default. Unsafe methods require an idempotency key or explicit retry opt-in. Retry-After is honored.

All API failures derive from FreeAstroError. Specific subclasses cover authentication, permission, validation, conflict, rate limit, server, network, and timeout failures.

Development

uv sync
uv run ruff check .
uv run mypy
uv run pytest
uv run python -m build

src/freeastroapi/_generated.py and src/freeastroapi/schemas.py are generated from spec/freeastro.json. To update them, copy the API's public-spec/openapi/freeastro.json into spec/ and run uv run python scripts/generate.py. CI runs python scripts/generate.py --check.

Releasing

Bump version in pyproject.toml and __version__ in src/freeastroapi/__init__.py, update CHANGELOG.md, then push a matching tag (git tag v0.2.0 && git push origin v0.2.0). The Release workflow runs the checks, builds, and publishes to PyPI with trusted publishing.

Issues and contributions are welcome on GitHub.

Licensed under Apache License 2.0.

Metadata

Release files for freeastroapi 0.2.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 freeastroapi 0.2.0
File Size Uploaded Provenance Actions
freeastroapi-0.2.0.tar.gz 230.3 kB With provenance Details for freeastroapi-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 304.3 kB

Release files / freeastroapi-0.2.0.tar.gz

Download URL freeastroapi-0.2.0.tar.gz
Size 230.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c25332e57470eedbd7c142eee29cf6ebb7e579f0e3f8ca995f7515091e8aa071
BLAKE2b-256 checksum
How to use checksums
c8d7e0bb1315769f6fa234b283d156f5865b757ad7f596e2fdde314c5e13742f
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 11, 2026.

Transparency log

Release files / freeastroapi-0.2.0-py3-none-any.whl

Download URL freeastroapi-0.2.0-py3-none-any.whl
Size 74.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
918b6f8d6d4a0fafafa3fb7891b74d5fd6aff0b2ea5edbd5fe7d96ff0bc554e8
BLAKE2b-256 checksum
How to use checksums
88526e58ff6846c3df3f78be8645261c02c1e3d9a48b29d35f76ea0061e36145
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 11, 2026.

Transparency log

Security for freeastroapi 0.2.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 freeastroapi-0.2.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 11, 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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

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