Vedic Astrology API for JavaScript and Node.js — Complete Integration Guide
Everything you need to call the VedIntel™ AstroAPI from any JavaScript environment — vanilla fetch, axios, Next.js App Router, React hooks, and Express. Copy-paste examples that work today.
In this guide
Calling the Astrology API with fetch() in JavaScript
The VedIntel™ AstroAPI is a pure REST GET API — no SDK required. Every endpoint takes query parameters and returns JSON. Here is the minimal pattern using native fetch():
// Vanilla JS / browser / Node 18+
const API_KEY = 'your_api_key_here';
const BASE = 'https://vedintelastroapi.com/api/v1';
async function getPlanetDetails(dob, tob, lat, lon, tz) {
const params = new URLSearchParams({ api_key: API_KEY, dob, tob, lat, lon, tz });
const res = await fetch(`${BASE}/horoscope/planet-details?${params}`);
if (!res.ok) throw new Error(`API error ${res.status}`);
return res.json(); // { status: 200, response: {...}, remaining_api_calls: N }
}
// Usage
const data = await getPlanetDetails('01/10/1977', '11:40', 11, 77, 5.5);
console.log(data.response.planets); // Array of 9 planet objectsVedic Astrology API with axios in Node.js
For server-side Node.js applications, axios gives you cleaner defaults, interceptors for error handling, and automatic base URL management. This pattern works in Express, Fastify, and any Node.js runtime:
// Node.js / React (with axios)
import axios from 'axios';
const astro = axios.create({
baseURL: 'https://vedintelastroapi.com/api/v1',
params: { api_key: process.env.ASTRO_API_KEY },
timeout: 10_000,
});
// Get full kundali
export async function getKundali(birthData) {
const { data } = await astro.get('/horoscope/planet-details', {
params: {
dob: birthData.dob, // 'DD/MM/YYYY'
tob: birthData.tob, // 'HH:MM'
lat: birthData.lat,
lon: birthData.lon,
tz: birthData.tz,
},
});
return data.response;
}
// Get today's panchang
export async function getPanchang(lat, lon, tz) {
const today = new Date();
const dob = `${today.getDate()}/${today.getMonth()+1}/${today.getFullYear()}`;
const { data } = await astro.get('/panchang/panchang', {
params: { dob, tob: '06:00', lat, lon, tz },
});
return data.response;
}Vedic Astrology API in a Next.js App Router Project
With Next.js App Router, call the astrology API directly from server components for zero client-side API key exposure. Use next: { revalidate: 3600 } for ISR — cached chart data served instantly on repeat loads:
// Next.js App Router — server component
// app/chart/page.tsx
async function getChart(dob: string, tob: string, lat: number, lon: number, tz: number) {
const params = new URLSearchParams({
api_key: process.env.ASTRO_API_KEY!,
dob, tob,
lat: lat.toString(),
lon: lon.toString(),
tz: tz.toString(),
});
const res = await fetch(
`https://vedintelastroapi.com/api/v1/horoscope/planet-details?${params}`,
{ next: { revalidate: 3600 } } // ISR — cache for 1 hour
);
return res.json();
}
export default async function ChartPage() {
const chart = await getChart('01/10/1977', '11:40', 11, 77, 5.5);
return (
<div>
<h1>Vedic Chart</h1>
{chart.response.planets.map((p: any) => (
<p key={p.name}>{p.name}: {p.sign} ({p.house}th house)</p>
))}
</div>
);
}React Hook for Vedic Chart Data — useKundali
For client-side React apps (CRA, Vite, React Native), encapsulate the API call in a custom hook. Note: proxy through your own backend in production — never expose your API key in client-side JS:
// React hook — useKundali.ts
import { useState, useEffect } from 'react';
interface BirthData {
dob: string; // DD/MM/YYYY
tob: string; // HH:MM
lat: number;
lon: number;
tz: number;
}
export function useKundali(birthData: BirthData | null) {
const [planets, setPlanets] = useState(null);
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
if (!birthData) return;
setLoading(true);
const params = new URLSearchParams({
api_key: process.env.NEXT_PUBLIC_ASTRO_KEY!,
...Object.fromEntries(Object.entries(birthData).map(([k,v]) => [k, String(v)])),
});
fetch(`/api/v1/horoscope/planet-details?${params}`)
.then(r => r.json())
.then(d => { setPlanets(d.response.planets); setLoading(false); })
.catch(e => { setError(e.message); setLoading(false); });
}, [JSON.stringify(birthData)]);
return { planets, loading, error };
}Most-Used Astrology API Endpoints for JavaScript Apps
Here are the endpoints JavaScript developers reach for most, with ready-to-paste examples:
// Get current Mahadasha period
async function getCurrentMahadasha(birthData) {
const params = new URLSearchParams({ api_key: API_KEY, ...birthData });
const res = await fetch(`${BASE}/dashas/current-mahadasha?${params}`);
const { response } = await res.json();
// response.major_period.lord → 'Jupiter'
// response.major_period.end_date → '2033-08-03'
// response.minor_period.lord → 'Saturn'
return response;
}
// Get kundali matching score (for matrimony apps)
async function getMatchScore(boy, girl) {
const params = new URLSearchParams({
api_key: API_KEY,
m_dob: boy.dob, m_tob: boy.tob,
m_lat: boy.lat, m_lon: boy.lon, m_tz: boy.tz,
f_dob: girl.dob, f_tob: girl.tob,
f_lat: girl.lat, f_lon: girl.lon, f_tz: girl.tz,
});
const res = await fetch(`${BASE}/matching/south-match?${params}`);
const { response } = await res.json();
// response.total_points → 28 (out of 36)
return response;
}/horoscope/planet-detailsAll 9 planet positions/horoscope/divisional-chartsD1–D60 navamsa etc./dashas/mahadashaFull Vimshottari timeline/dashas/current-mahadashaActive dasha + antardasha/panchang/panchangDaily panchang/matching/south-matchKundali matching score/dosha/mangal-doshMangal dosha check/extended-horoscope/yoga-listYoga detection/ai/chatAI astrologer (Claude)/horoscope/chart-imageSVG kundali chartEnvironment Variables and API Key Security
Never put your API key in client-side JavaScript. The standard pattern:
# .env.local (Next.js) or .env (Node.js) ASTRO_API_KEY=vai_live_xxxxxxxxxxxxxxxxxxxx # Server component / API route — safe process.env.ASTRO_API_KEY # Client component — NEVER do this process.env.NEXT_PUBLIC_ASTRO_API_KEY ← exposes key in browser bundle
For React SPA or React Native: create a thin Express/Next.js API route that proxies to VedIntel™ AstroAPI. Your API key stays server-side, and your users call your-api.com/chart instead.
Date Format: What JavaScript Developers Need to Know
The API expects DD/MM/YYYY for date and HH:MM (24-hour) for time. Convert from a JS Date object:
function toAPIDate(date: Date): string {
const d = String(date.getDate()).padStart(2, '0');
const m = String(date.getMonth() + 1).padStart(2, '0');
const y = date.getFullYear();
return `${d}/${m}/${y}`; // → '01/10/1977'
}
function toAPITime(date: Date): string {
const h = String(date.getHours()).padStart(2, '0');
const m = String(date.getMinutes()).padStart(2, '0');
return `${h}:${m}`; // → '11:40'
}Start building your JavaScript astrology app today
500 free API calls. No credit card. Works with any JS framework in under 10 minutes.