The official Node.js / TypeScript client library for AiAstroAPI — a high-precision Vedic Astrology, Panchang, and planetary computing engine.
Get instant, type-safe access to birth charts (D1-D60), Vimshottari Dashas, Ashtakoot/Dashakoot matchmaking, transit tracking, and AI-powered readings.
Install the package via npm:
npm install @aiastroapi/sdkOr via yarn / pnpm:
yarn add @aiastroapi/sdk
# or
pnpm add @aiastroapi/sdkInitialize the AiAstroClient with your API key.
import { AiAstroClient } from '@aiastroapi/sdk';
const client = new AiAstroClient({
apiKey: 'YOUR_API_KEY'
});The SDK supports clean, object-based parameter calls. Define your parameters once and reuse them across multiple calculations.
import { AiAstroClient } from '@aiastroapi/sdk';
const client = new AiAstroClient({ apiKey: 'YOUR_API_KEY' });
// Define birth details configuration
const birthDetails = {
year: 1991,
month: 1,
day: 1,
hour: 12,
min: 0,
lat: 23.179,
lon: 75.785,
tz: 5.5
};
// Fetch planet details
const planets = await client.getPlanets(birthDetails);
console.log("Ascendant Sign:", planets[0].sign);
// Fetch Panchang details
const panchang = await client.getPanchang(birthDetails);
console.log("Nakshatra of the day:", panchang.nakshatra);Fetch raw calculations or beautifully styled SVG representations for divisional charts:
// 1. Fetch raw JSON calculations
const d9Data = await client.getChartData(birthDetails, 'D9');
// 2. Fetch SVG representation (supports 'north' / 'south' styles)
const d10Svg = await client.getChartSvg(birthDetails, 'D10', 'north');For matchmaking, group parameters under male and female keys:
const matchParams = {
male: {
year: 1991, month: 1, day: 1, hour: 12, min: 0, lat: 23.179, lon: 75.785, tz: 5.5
},
female: {
year: 1994, month: 5, day: 14, hour: 10, min: 30, lat: 18.9, lon: 72.8, tz: 5.5
}
};
const compatibility = await client.getAshtakootMatch(matchParams);
console.log("Match compatibility points (out of 36):", compatibility.ashtakoot_points);Generate contextual readings directly through the production worker pipeline:
const careerReport = await client.getAiReport('career', birthDetails);
console.log(careerReport.ai_prediction);The SDK throws structured errors for bad requests, invalid parameters, or authentication failures. It is highly recommended to wrap requests in standard try/catch blocks:
try {
const result = await client.getPanchang({
year: 1991,
month: 1,
day: 35, // <-- Invalid day parameter!
lat: 23.179,
lon: 75.785,
tz: 5.5
});
} catch (error) {
console.error("API Request Failed:", error.message);
}- 🌐 Developer Portal: dev.aiastroapi.com
- 📚 API Documentation: aiastroapi.com/docs
- 📦 NPM Registry: @aiastroapi/sdk
- 📄 License: MIT License