astro96-api
The official Python client for the 96Astro API: Vedic and Western astrology, panchang, matching, reports and AI readings over one JSON API.
- Sync (
Astro96Client) and asyncio (AsyncAstro96Client) clients onhttpx, Python 3.9+ - A typed method for every capability, generated from the OpenAPI document (
TypedDictrequest bodies) - Retries with backoff on
429/503(honouringRetry-After), automatic idempotency keys so a retry is never charged twice ApiErrorwithcode,field,retryableandrequest_id; rate-limit headers on every response- PDF job helpers (
create_pdf_job,wait_for_job,download_file,render_pdf) and webhook signature verification
Not on PyPI yet. Publishing is in progress; until then
pip install astro96-apiwill not find the package. Contact support for a pre-release wheel, or build it from this repository (see Development).
Install
pip install astro96-api
Quickstart
from astro96_api import Astro96Client
astro = Astro96Client() # reads ASTRO_API_KEY (sk_test_... or sk_live_...)
res = astro.vedic_charts.planet_positions(
{"datetime": "1990-10-18T14:30:00", "timezone": "Asia/Kolkata", "latitude": 28.6139, "longitude": 77.209}
)
print(res.data["ascendant"]["sign"], res.meta["credits_used"], res.rate_limit)
import asyncio
from astro96_api import AsyncAstro96Client
async def main() -> None:
async with AsyncAstro96Client() as astro:
res = await astro.panchang.daily_panchang(
{"date": "2026-10-15", "timezone": "Asia/Kolkata", "latitude": 28.6139, "longitude": 77.209}
)
print(res.data)
asyncio.run(main())
POST /v1/{family}/{capability} is client.family.capability() in snake_case. Each call returns an ApiResponse with data, meta, status, request_id, rate_limit, replayed, idempotency_key and headers.
Response data is typed as a TypedDict of its top-level fields, from each endpoint's published schema: a hand-written contract for the main endpoints, and for almost all others a schema measured from several real answers (a required field was in every answer). A few have only the schema inferred from one example. An answer to an input none of the samples covered can still differ, so check optional fields. Nested objects are plain dicts.
Errors
from astro96_api import ApiConnectionError, ApiError
try:
astro.vedic_charts.planet_positions(birth)
except ApiError as e:
print(e.status, e.code, e.field, e.retryable, e.request_id)
except ApiConnectionError as e:
print("network", e.timed_out)
Retries and idempotency
429 rate_limited and 503 are retried after Retry-After (up to max_retry_delay, default 30 s). Other retryable errors and network failures are retried only when the call has an idempotency key, which every POST gets automatically (auto_idempotency=True) and keeps across retries. quota_exhausted is never retried. Pass your own key to retry across processes:
from astro96_api import idempotency_key
astro.reports.report_career(birth, idempotency_key=stored_key or idempotency_key())
Client options: api_key, base_url, auth ("bearer" or "x-api-key"), timeout (60 s), max_retries (2), max_retry_delay, auto_idempotency, headers, http_client. Per call: idempotency_key=, timeout=, max_retries=, headers=.
PDF reports
pdf = astro.render_pdf("report-career", birth, branding={"brand_name": "Shree Jyotish Kendra"})
# or step by step: create_pdf_job -> wait_for_job -> download_file
Webhooks
from astro96_api import verify_webhook
event = verify_webhook(raw_body, headers, os.environ["ASTRO_WEBHOOK_SECRET"])
Full guide: https://96astroapi.com/docs/sdks
Not wrapped yet: AI streaming (
stream: true/Accept: text/event-stream), the/v1/conversationsroutes and.icscalendar export. These clients always ask for JSON; call those routes over plain HTTP (see https://96astroapi.com/docs/ai-streaming-and-chat). Everything else, including the image options (image_format,image_theme,image_delivery), works through the typed inputs.
Name your app (optional)
Optional: tell the API which app is calling, so you can see where your keys are used (the dashboard's Where your keys are used) and spot a leaked key.
astro = Astro96Client(api_key=key, app_info={"name": "Acme Shop", "version": "2.1.0", "url": "https://shop.acme.com"})
The name is required (printable ASCII, at most 60 characters, no / or parentheses); the version (at most 40) and the url (http(s), at most 120) are optional. It is sent as the X-Astro-App header, never with your key; the API keeps the name, the version and only the host of the url. The User-Agent also carries the platform (plt/node, plt/linux...). An invalid value is refused when the client is created. (ValueError)
Development
The typed methods in src/astro96_api/_generated/ are written by tools/sdk/generate_python.py from packages/registry/openapi/v1.openapi.json; never edit them by hand.
python ../../tools/sdk/generate_python.py # regenerate after the OpenAPI document changes
python -m pytest # unit tests (httpx.MockTransport) + drift test
Publishing
- Set
nameinpyproject.tomlif it should differ fromastro96-api, bumpversion(andsrc/astro96_api/_version.py), and add alicenseandLICENSEfile. python ../../tools/sdk/generate_python.py --check && python -m pytestpython -m buildthenpython -m twine upload dist/*with a PyPI token for the project.
Audio reports
Any report can come back as a spoken MP3 in 26 languages, as a background job. Poll it as you would a PDF job. See Audio reports.
job = client.create_audio_job(
"report-career",
{"datetime": "1990-10-18T14:30:00", "timezone": "Asia/Kolkata", "latitude": 28.6139, "longitude": 77.209},
language="hi",
minutes=5,
)
Palm and face readings are ordinary calls that take a photo as base64: see Palm and face readings.
Metadata
Release files for astro96-api 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| astro96_api-0.3.2.tar.gz | 292.3 kB | Without provenance | Details for astro96_api-0.3.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| astro96_api-0.3.2-py3-none-any.whl | Python 3 | none | any | Details for astro96_api-0.3.2-py3-none-any.whl |
Total release size: 608.1 kB
Release files / astro96_api-0.3.2.tar.gz
| Download URL | astro96_api-0.3.2.tar.gz |
|---|---|
| Size | 292.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1f5cd1d654dc37aeede7e80d550b0a60588b7ea4292aec9ac9a295aea455cb91
|
|
BLAKE2b-256 checksum How to use checksums |
db75b0b1ab823ba778b252888b42fb94a04e7e8984744d3f30445bb4056ba258
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|
Release files / astro96_api-0.3.2-py3-none-any.whl
| Download URL | astro96_api-0.3.2-py3-none-any.whl |
|---|---|
| Size | 315.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a78f39ae8f6f7cbe367a93ba17cce6e6986ea1de9d3cee094cc3aec9a3c6f962
|
|
BLAKE2b-256 checksum How to use checksums |
2be388a3ec316bb218c99d1d290abff4872749098fa62de98bc45eff57861a4c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|
Security for astro96-api 0.3.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.