Real-world code examples for common use cases.
Display today's horoscope with Tithi, Nakshatra, and planetary positions.
const res = await fetch(
"https://astroapi.vedicmatters.com/api/v1/horoscope/daily",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": process.env.VEDASTRO_API_KEY
},
body: JSON.stringify({
date: new Date().toISOString().split("T")[0],
zodiacSign: "Leo",
location: {
"name": "Mumbai, India",
"latitude": 19.076,
"longitude": 72.8777
}
})
}
);
const { data } = await res.json();
// data.horoscope → daily prediction
// data.planetaryPositions → Sun, Moon, etc.Generate a Kundali when a user enters their birth details.
import requests
import os
def get_kundali(dob_time, place):
response = requests.post(
"https://astroapi.vedicmatters.com/api/v1/chart/birth",
headers={"X-API-Key": os.environ["VEDASTRO_API_KEY"]},
json={
"dateTime": dob_time, # "1990-01-15T08:30:00"
"location": place,
"ayanamsa": "LAHIRI"
}
)
return response.json()["data"]
kundali = get_kundali(
"1995-03-22T14:45:00",
{"name": "Chennai, India", "latitude": 13.0827, "longitude": 80.2707}
)
print(f"DateTime: {kundali['dateTime']}")
print(f"Location: {kundali['location']['name']}")Build a calendar view with daily Tithi, Nakshatra, and transitions.
import requests
import os
def get_month_panchang(month, year, location):
res = requests.post(
"https://astroapi.vedicmatters.com/api/v1/calendar/month",
headers={"X-API-Key": os.environ["VEDASTRO_API_KEY"]},
json={"month": month, "year": year, "location": location}
)
return res.json()["data"]
calendar = get_month_panchang(11, 2025, {"name":"Mumbai, India","latitude":19.076,"longitude":72.8777})
for day in calendar.get("days", []):
print(day.get("date"), day.get("tithi"), day.get("nakshatra"))Show a user's current Mahadasha and Antardasha.
const response = await fetch(
"https://astroapi.vedicmatters.com/api/v1/dasa/vimshottari",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": process.env.VEDASTRO_API_KEY
},
body: JSON.stringify({
"dateTime": "1990-01-15T08:30:00",
"location": {
"name": "Delhi, India",
"latitude": 28.6139,
"longitude": 77.209
}
})
}
);
const { data } = await response.json();
console.log("Dasa periods:", data);Answer a horary question at the time it was asked.
const response = await fetch(
"https://astroapi.vedicmatters.com/api/v1/prashna/analyze",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": process.env.VEDASTRO_API_KEY
},
body: JSON.stringify({
questionTime: new Date().toISOString(),
location: {"name":"Mumbai, India","latitude":19.076,"longitude":72.8777},
questionType: "Career",
ruleProfile: "prashna_analysis_v1"
})
}
);
const result = await response.json();
console.log(result);Try these live
All examples can be tested interactively in the API Playground — no code required.