Integrating a Vedic Astrology API in Next.js — Complete Guide with Code
This guide walks through integrating VedIntel™ AstroAPI into a Next.js 14 App Router project from zero to working feature — environment setup, server-side data fetching, client components, and real endpoint examples including planet positions, Lagna, Mahadasha, and Panchang.
Prerequisites
- Next.js 14+ with App Router
- A free VedIntel™ API key — get one here (500 calls/month, no credit card)
- Birth data: date (DD/MM/YYYY), time (HH:MM 24hr), latitude, longitude, timezone offset
Step 1 — Environment Setup
Add your API key to .env.local. Never expose it to the browser:
Step 2 — A Typed API Client
Create a small helper to call VedIntel endpoints. This runs server-side only:
Step 3 — Fetch Planet Positions in a Server Component
Step 4 — Current Mahadasha
In a Next.js route handler, call this from an API route to avoid exposing your key, or use the server component pattern from Step 3 directly.
Step 5 — Panchang for Today
The Panchang endpoint uses a date parameter instead of dob/tob:
Caching Strategy
Natal chart data (planet positions, Lagna, divisional charts) is immutable — the same birth data always returns the same result. Cache aggressively:
- Natal endpoints —
revalidate: false(cache forever, or useforce-cache) - Panchang / transit —
revalidate: 3600(hourly refresh is plenty) - Current dasha —
revalidate: 86400(daily — dashas don't change intra-day)
116 Endpoints, Free Tier Available
VedIntel™ covers horoscope, divisional charts, dashas, doshas, Panchang, kundali matching, numerology, and AI interpretation — all from one API key. Free plan: 500 calls/month, no credit card.