Documentation
SDKs and Postman
Official clients for TypeScript, Python, PHP, Java, .NET, Ruby, Swift, Dart/Flutter, Go and Rust, on their package registries, with retries and idempotency built in, plus a WordPress plugin and Postman.
Every SDK method and every Postman request is generated from the OpenAPI document, so they cover every capability in the API reference with the same names. The TypeScript and Python clients are described first; the PHP client, the WordPress plugin and Postman follow. The parts that make calls safe (retries, idempotency keys, errors, PDF and audio jobs, webhook signatures) are written by hand and tested.
| TypeScript / JavaScript | Python | |
|---|---|---|
| Package | @96astro/api | astro96-api (import astro96_api) |
| Runtime | Node.js 18+ (and other runtimes with fetch). Zero dependencies | Python 3.9+, sync and asyncio clients on httpx |
| Formats | ESM and CommonJS, with type declarations | Typed (py.typed), TypedDict inputs |
The official SDKs are published on npm, PyPI, Packagist, NuGet, Maven Central, RubyGems, Swift Package Manager, pub.dev, the Go module proxy (github.com/96astro/astro96-go) and crates.io. Every SDK is generated from the same registry as the API reference, so a new capability reaches all of them in the next release; each registry page shows the current version. See Go and Rust for those two, and the Postman collection if you would rather start from ready-made requests.
Install
# TypeScript / JavaScript
npm install @96astro/api
# Python
pip install astro96-api
# PHP
composer require 96astro/api
# Go
go get github.com/96astro/astro96-go
# Rust
cargo add astro96-apiThe Java, .NET, Ruby, Swift and Dart/Flutter install lines are below.
Both clients read the key from the ASTRO_API_KEY environment variable when you do not pass one.
Keys belong on your server. The TypeScript client refuses to start in a browser unless you pass dangerouslyAllowBrowser: true, because a key in a web page is visible to every visitor.
Your first call
TypeScript
import { Astro96Client } from "@96astro/api";
const astro = new Astro96Client({ apiKey: process.env.ASTRO_API_KEY });
const { data, meta, rateLimit } = await astro.vedicCharts.planetPositions({
datetime: "1990-10-18T14:30:00",
timezone: "Asia/Kolkata",
latitude: 28.6139,
longitude: 77.209,
});
console.log(data.ascendant.sign, data.planets.length, meta.credits_used, rateLimit?.remaining);Python
from astro96_api import Astro96Client
astro = Astro96Client() # reads ASTRO_API_KEY
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)Python, async
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())Methods follow the URL: POST /v1/{family}/{capability} is client.family.capability(), in camelCase for TypeScript (astro.doshasYogas.manglikDosha) and snake_case for Python (astro.doshas_yogas.manglik_dosha). Each call returns the response's data and meta, plus status, requestId, rateLimit (the RateLimit-* headers), replayed, the idempotencyKey that was sent and headers, all the response headers: read headers.get("X-Credits-Remaining") for your balance.
Types
Request bodies are typed from the OpenAPI request schemas, so your editor knows every field, its limits and its default. Response types (data) come from each endpoint's published response schema. For the main endpoints that is a hand-written contract (x-schema-source: authored). For almost every other endpoint it is measured from several real answers to different inputs (sampled): a required field was in every answer, and a field is null-able only where an answer had null. An answer to an input none of them covered can still differ, so check optional fields before you rely on them. A few endpoints have only the schema inferred from one example (example), which is a guide to the shape, not a contract. In Python, response data is a TypedDict of its top-level fields with nested objects as plain dicts.
Errors
A failed call raises an ApiError with the fields of the error envelope: status, code (stable: program against it), field, retryable and requestId. A network failure or timeout raises ConnectionError (ApiConnectionError in Python).
import { ApiError } from "@96astro/api";
try {
await astro.vedicCharts.planetPositions({ datetime: "1990-10-18T14:30:00", latitude: 99, longitude: 77.2 });
} catch (err) {
if (err instanceof ApiError && err.code === "invalid_request") {
console.error(`Fix ${err.field}: ${err.message} (request ${err.requestId})`);
} else {
throw err;
}
}from astro96_api import ApiError
try:
astro.vedic_charts.planet_positions({"datetime": "1990-10-18T14:30:00", "latitude": 99, "longitude": 77.2})
except ApiError as e:
if e.code == "quota_exhausted":
... # top up or upgrade; retrying will not help
print(e.status, e.code, e.field, e.request_id)Retries and idempotency
The clients retry for you, with exponential backoff and jitter, up to maxRetries (max_retries, default 2):
429 rate_limitedand503are retried after the server'sRetry-After. If it asks for longer thanmaxRetryDelayMs(max_retry_delay, default 30 seconds), the error is raised instead so you can decide.429 quota_exhaustedis never retried.- Other errors marked
retryable(500,502,504, an idempotency key still in progress) and network failures are retried only when the call carries an idempotency key, so a retry can never be charged twice.
Every POST gets an Idempotency-Key automatically, reused across the client's own retries. To retry safely across processes (say, a job queue), pass your own key and reuse it for the same logical operation:
import { idempotencyKey } from "@96astro/api";
const key = order.idempotencyKey ?? idempotencyKey(); // store it with the order
await astro.reports.reportCareer(birth, { idempotencyKey: key });from astro96_api import idempotency_key
key = order.idempotency_key or idempotency_key() # store it with the order
astro.reports.report_career(birth, idempotency_key=key)Turn automatic keys off with autoIdempotency: false (auto_idempotency=False). See Idempotency for how the API replays a repeated key.
Options
| TypeScript | Python | Default | Meaning |
|---|---|---|---|
apiKey | api_key | ASTRO_API_KEY | Your sandbox or live key |
baseUrl | base_url | https://api.96astroapi.com | API address |
auth | auth | "bearer" | "bearer" or "x-api-key" header |
timeoutMs | timeout | 60 s | Per attempt |
maxRetries | max_retries | 2 | Retries after the first attempt |
fetch | http_client | global fetch / new httpx client | Bring your own transport, proxy or mock |
Each method also takes per-call options: idempotencyKey, timeoutMs, maxRetries, headers and an AbortSignal to cancel (Python: idempotency_key=, timeout=, max_retries=, headers=; cancel an asyncio task to stop an async call).
Name your app
Every SDK takes an optional app identity, so you can see which app, website or platform calls the API with your keys. It is off unless you set it. Browser calls already show their website; server-side and mobile calls show only the SDK, so naming the app is what tells your apps apart (and helps you spot a leaked key: an app you do not recognise).
| Language | How |
|---|---|
| TypeScript | new Astro96Client({ appInfo: { name: "Acme Shop", version: "2.1.0", url: "https://shop.acme.com" } }) |
| Python | Astro96Client(app_info={"name": "Acme Shop", "version": "2.1.0", "url": "https://shop.acme.com"}) |
| PHP | new Client($key, ['app_info' => ['name' => 'Acme Shop', 'version' => '2.1.0', 'url' => 'https://shop.acme.com']]) |
| Go | astro96.NewClient(key, astro96.WithAppInfo("Acme Shop", "2.1.0", "https://shop.acme.com")) |
| Rust | Client::builder(key).app_info("Acme Shop", Some("2.1.0"), Some("https://shop.acme.com")) |
| Java, .NET, Ruby, Swift, Dart | optional constructor parameters (appName, appVersion, appUrl; Ruby app_info:; Swift appInfo: Astro96AppInfo(...)) |
The name is required: printable ASCII, at most 60 characters, without / or parentheses. The version (at most 40 characters) and the url (http or https, at most 120 characters) are optional, and neither may contain spaces or parentheses. An invalid value is refused when the client is created. The SDK sends it as the X-Astro-App header in the form name/version (+url); if you call the API without an SDK you can send the header yourself. It never contains your key.
The API stores the name, the version and only the host of the url (never a path or query), together with the platform it works out from the User-Agent (ios, android, web, server, desktop or unknown; the SDKs add a plt/ token such as plt/node or plt/linux). They are shown under Usage > Where your keys are used in your dashboard, for your organization only, and are deleted with your account like the IP address and User-Agent.
Not wrapped yet
The SDKs call the JSON capabilities and the PDF and audio job routes. They do not yet wrap streaming (stream: true needs a reader for text/event-stream), the /v1/conversations routes, or .ics calendar export (the clients always ask for JSON). Call those over plain HTTP as shown in their guides; the key, retries and idempotency rules are the same. Image options (image_format, image_theme, image_delivery and the rest) are ordinary request fields and work in the typed inputs.
PDF reports
createAudioJob makes a spoken MP3 of a report the same way. createPdfJob, waitForJob and downloadFile wrap the PDF job routes. waitForJob polls with a growing interval (2 s to 10 s, up to 5 minutes by default) and raises JobError if the job fails. downloadFile fetches the signed link without your key and refreshes an expired link once.
import { writeFile } from "node:fs/promises";
const birth = { datetime: "1990-10-18T14:30:00", timezone: "Asia/Kolkata", latitude: 28.6139, longitude: 77.209 };
const { job, pdf } = await astro.renderPdf({
capability: "report-career",
input: birth,
branding: { brand_name: "Shree Jyotish Kendra", accent: "#1f4fd1" },
});
await writeFile(`career-${job.id}.pdf`, pdf);job = astro.create_pdf_job("report-career", birth, branding={"brand_name": "Shree Jyotish Kendra"}).data
done = astro.wait_for_job(job, timeout=300)
with open(f"career-{done['id']}.pdf", "wb") as f:
f.write(astro.download_file(done))Webhooks
verifyWebhook (verify_webhook) checks the Astro-Signature of a webhook against your endpoint's secret (or several, while you rotate), refuses timestamps more than 5 minutes off, compares in constant time and returns the parsed event. Pass the raw request body.
import express from "express";
import { verifyWebhook, WebhookSignatureError } from "@96astro/api";
app.post("/webhooks/96astro", express.raw({ type: "application/json" }), async (req, res) => {
try {
const event = await verifyWebhook({ rawBody: req.body, headers: req.headers, secret: process.env.ASTRO_WEBHOOK_SECRET! });
// Deduplicate on event.id, queue the work, then answer quickly.
res.sendStatus(204);
} catch (err) {
if (err instanceof WebhookSignatureError) return res.status(400).send("bad signature");
throw err;
}
});import os
from astro96_api import WebhookSignatureError, verify_webhook
try:
event = verify_webhook(request.body, request.headers, os.environ["ASTRO_WEBHOOK_SECRET"])
except WebhookSignatureError:
return 400PHP
A PHP client, 96astro/api (PHP 8.1+, namespace Astro96\Api), is built and tested with the same safety features: retries on 429 and 503 honouring Retry-After, automatic idempotency keys, typed exceptions per error code, PDF job helpers and webhook verification. It uses the WordPress HTTP API inside WordPress, Guzzle when installed, otherwise ext-curl or any PSR-18 client, and includes an optional Laravel service provider and Astro96 facade.
composer require 96astro/apiuse Astro96\Api\Client;
$astro = new Client(); // reads ASTRO_API_KEY
$res = $astro->vedicCharts->planetPositions([
'datetime' => '1990-10-18T14:30:00', 'timezone' => 'Asia/Kolkata',
'latitude' => 28.6139, 'longitude' => 77.209,
]);
echo $res->data['ascendant']['sign'];POST /v1/{family}/{capability} is $astro->family->capability() in camelCase, for example $astro->panchang->dailyPanchang([...]). $astro->call($path, $input) sends any other JSON POST route; streaming, .ics and the GET conversation routes are not wrapped.
WordPress
The WordPress plugin sells personalised PDF and MP3 reports through WooCommerce (below), and adds blocks and shortcodes to any WordPress 6.3+ site (PHP 7.4+): [astro96_panchang], [astro96_horoscope sign="leo" period="weekly"], [astro96_kundli style="south"], [astro96_match], [astro96_western] (a Western natal wheel with the Sun, Moon and rising sign) and [astro96_numerology] (radical, destiny, name and Kua numbers). Your site calls the API with your key from the server, so the key is never in a page; identical requests are cached, so repeated views cost no credits, and each visitor can submit the kundli and matching forms only a limited number of times an hour.
- Download the plugin and upload it under Plugins, Add New, Upload Plugin. The current version is 1.2.1. Version 1.1.1 was submitted to the WordPress.org directory and is awaiting review, so for now install it from the zip.
- Under Settings, 96Astro API paste a secret key (
sk_test_...to try it,sk_live_...to go live) and set your default city. Test the connection checks the key. - Add a 96Astro block to a page, or a shortcode.
Selling reports with WooCommerce
With WooCommerce active, any product can be a personalised report. In the product's 96Astro report tab choose the report (kundli, career, marriage, annual, five-year, past-life, child personality, Big Three and more), PDF or narrated MP3, the language, and for MP3 the voice, style, minutes, podcast format and music.
-
Buyers enter birth details on the product page; the server checks them before the item goes in the cart.
-
When the order is paid, each report item becomes one job. Its
Idempotency-Keynames the site, order, item and attempt, so a repeated payment hook never makes or charges a second report. -
WP-Cron polls the job. The finished file is kept in a protected
uploads/astro96-reportsfolder, and the buyer is emailed a personal link (also shown in their order) that serves the file only for that order. -
On Nginx, block the folder yourself. The plugin protects it with an
.htaccessfile, which Apache obeys and Nginx ignores. Add this to the site'sserverblock (on Plesk: Apache & nginx Settings, Additional nginx directives; on a managed host, ask support to add it), then reload Nginx:location ^~ /wp-content/uploads/astro96-reports/ { deny all; }Check it:
curl -I https://your-shop.example/wp-content/uploads/astro96-reports/test.pdfshould answer403, while the download link in an order email still works. -
A failed report is retried up to three times; then the order gets a note and the site admin an email.
-
Your brand name, accent colour, footer and website (Settings, 96Astro API) print on the PDFs.
A live key spends your credits for each report sold; a sandbox key makes sample reports free while you set up.
A calculated answer shows a small "Calculated by 96Astro API" line; remove it with add_filter( 'astro96_show_credit', '__return_false' );. Behind Cloudflare or another proxy, pass the visitor's real address with the astro96_client_ip filter so the hourly limit is per visitor. To draw the panels in the browser instead, use the widgets.
Postman
Download the Postman collection and an environment (Sandbox or Live), then import them in Postman (Import, drop the files).
- Select the environment and paste your key into
api_key. The files carry no key. Start with a sandbox key (sk_test_...): calls are not charged. - The collection authenticates every request with
Authorization: Bearer {{api_key}}and sends a freshIdempotency-Key({{$guid}}). Replace it with a fixed value to try a replay. - Requests are grouped by family, with the documented example body and a saved example response.
The whole collection is large. If you use only some families, import just those:
| Family | Collection |
|---|---|
| Vedic | Download |
| Strengths & relationships | Download |
| Dasha systems | Download |
| Panchang & almanac | Download |
| Festivals & muhurta | Download |
| Compatibility matching | Download |
| Doshas & yogas | Download |
| Predictions & readings | Download |
| Krishnamurti Paddhati (KP) | Download |
| Jaimini | Download |
| Lal Kitab | Download |
| Bhrigu Nandi Nadi (BNN) | Download |
| Annual charts (Tajika) | Download |
| Western astrology | Download |
| Tarot | Download |
| Numerology | Download |
| Remedies & guidance | Download |
| Reports | Download |
| Location astrology | Download |
| Vastu | Download |
| Mundane astrology | Download |
| AI interpretation | Download |
| Utilities | Download |
| Chinese astrology | Download |
| Human Design | Download |
| Palm reading | Download |
| Face reading | Download |
- The PDF and audio jobs folder chains create, poll and download: its scripts carry
job_idanddownload_urlfrom one request to the next.
Other languages
Any language with an HTTP client can call the API: see the Quickstart and Requests and responses. The OpenAPI 3.1 document also works with generators such as OpenAPI Generator.
Java, Android, .NET, Ruby and Swift
Clients with one method per capability, retries and idempotency keys, and no dependencies. Each language has a full guide: install, first call, errors, retries, PDF and audio jobs, and webhook verification. Requests and responses are JSON strings, so you parse them with whatever your app already uses (Ruby takes a Hash and parses the answer).
| Language | Install | Tested on | Full guide |
|---|---|---|---|
| Java and Android | Maven: com.96astroapi:astro96-api (Gradle: implementation("com.96astroapi:astro96-api:<version>"), the latest version is on Maven Central) | Java 8 | Java and Android SDK |
| .NET | dotnet add package Astro96.Api | .NET 8 | .NET SDK |
| Ruby | gem install astro96 (or gem "astro96" in your Gemfile) | Ruby 3.0 | Ruby SDK |
| Swift | Swift Package Manager: .package(url: "https://github.com/96astro/astro96-swift.git", from: "0.2.0") (any later 0.x release also satisfies it) | Swift 5.9 | Swift SDK |
Each is checked for its requests, retries and errors, and makes one real call to the API. The Java package is com.astro96 (import com.astro96.Astro96Client;): a Java package name cannot start with a digit, so it differs from the Maven group.
Prefer files? Each is also a download with a README and the MIT licence: Java, .NET, Ruby, Swift, Go, Rust.
Go and Rust
Both are generated from the same registry, with one method per capability, PDF and audio jobs, retries that reuse the idempotency key, and an error carrying the API's code.
| Language | Install | Tested |
|---|---|---|
| Go | go get github.com/96astro/astro96-go (module path as above; standard library only; the module is released from the repository with tags of the form packages/sdk-go/vX.Y.Z) | go vet, go build and go test on Go 1.21 |
| Rust | cargo add astro96-api (crate astro96-api, import astro96_api; async on reqwest with rustls) | cargo test, and the shared request, retry and error check in Docker |
import astro96 "github.com/96astro/astro96-go"
client, err := astro96.NewClient(os.Getenv("ASTRO_API_KEY"))
answer, err := client.PlanetPositions(ctx, map[string]any{
"datetime": "1990-10-18T14:30:00", "timezone": "Asia/Kolkata",
"latitude": 28.6139, "longitude": 77.209,
})let client = astro96_api::Client::new(std::env::var("ASTRO_API_KEY")?)?;
let answer = client
.planet_positions(serde_json::json!({
"datetime": "1990-10-18T14:30:00", "timezone": "Asia/Kolkata",
"latitude": 28.6139, "longitude": 77.209
}))
.await?;
println!("{} credits used", answer.meta.credits_used);The Go client takes a struct, map, JSON string or []byte and returns the response JSON; the Rust client takes a serde_json::Value and returns an envelope with data and meta (request_id, credits_used). Each folder has a README, and each is also a zip download (Rust) with the MIT licence.
Dart and Flutter
astro96_api on pub.dev, for Dart 3 on servers, the command line and every Flutter platform. It has the same shape as the clients above: one method per capability, PDF and audio jobs, retries with idempotency keys, and an Astro96Exception carrying the API's code. Each method takes the request as a Map (or a JSON string) and returns the parsed response.
dart pub add astro96_api # or: flutter pub add astro96_apiimport 'dart:io';
import 'package:astro96_api/astro96_api.dart';
// On your server: the key comes from the environment, never from app code.
final astro = Astro96Client(apiKey: Platform.environment['ASTRO_API_KEY']!);
final answer = await astro.planetPositions({
'datetime': '1990-10-18T14:30:00',
'timezone': 'Asia/Kolkata',
'latitude': 28.6139,
'longitude': 77.209,
});Never ship your secret key inside a Flutter app: have the app call your own backend, and let the backend call the API (see Platforms). The Dart and Flutter SDK guide covers errors, retries, PDF and audio jobs and webhooks.
Was this page helpful?
Quickstart
From sign-up to your first birth chart in a few minutes: get a free sandbox key, make one curl call, then switch to an SDK.
Java and Android SDK
Install the 96Astro API client for Java and Android from Maven Central, make your first call, handle errors and retries, create PDF and audio reports, and verify webhooks.


