Python astrology API quickstart
Official client on PyPI.
Python is the one language with a published AstroNode client. It wraps every operation as a named method, unwraps the response envelope for you, and raises typed errors. You can still drop to raw HTTP for anything it does not cover.
`aie-api-client` is the official Python client (`sdks/python/api-client` in the monorepo). Sync and async clients, one method per operation.
Step 1
Install
One package. It has no heavy dependencies and ships type hints.
pip install aie-api-client
Step 2
Keep the key out of your code
The key authenticates every call and should never reach a client bundle or a commit. Put it in the environment and read it from there.
# .env (git-ignored) ASTRONODE_API_KEY=aie_test_your_key_here
Step 3
Make the call
Named methods mirror the endpoint paths, and return the unwrapped `data` payload directly.
import os
from aie_api_client import ApiClient
aie = ApiClient(
api_key=os.environ["ASTRONODE_API_KEY"],
base_url="https://api.astronode.dev",
)
chart = aie.charts.birth({
"date": "1993-07-04",
"time": "09:27:11",
"tz_offset_minutes": 330,
"lat": 31.7473,
"lng": 77.7754
})
print(chart["ascendant"], len(chart["planets"]))Step 4
Handle errors
The client raises instead of returning a status, so ordinary try/except is the whole story.
from aie_api_client.errors import ApiError, ConnectionError, TimeoutError
try:
chart = aie.charts.birth({"date": "not-a-date"})
except ApiError as e:
# 4xx / 5xx from the API - carries the code and message from the envelope.
print(e.status, e.code, e.message)
except (ConnectionError, TimeoutError) as e:
# Network-level: retry or fall back.
print("unreachable:", e)Step 5
Anything not wrapped
`request` returns the full envelope, `data` returns just the payload - so a brand-new endpoint is callable the day it ships.
envelope = aie.request("POST", "/v1/yogas", json={
"date": "1993-07-04",
"time": "09:27:11",
"tz_offset_minutes": 330,
"lat": 31.7473,
"lng": 77.7754
})
print(envelope["meta"]["engine_version"])
payload = aie.data("POST", "/v1/yogas", json={
"date": "1993-07-04",
"time": "09:27:11",
"tz_offset_minutes": 330,
"lat": 31.7473,
"lng": 77.7754
})Next
Where to go from here
The call above is one of 110 endpoints. They all take the same bearer token and return the same envelope, so the second one is a path change. Each endpoint page carries its request fields and constraints.
Free tier covers 1,000 requests / month. No card, and test keys work on every endpoint.
Other languages