Panchang API for Mobile and Web Applications
API TUTORIAL

Panchang API for Apps: Hindu Calendar Integration

Complete guide to integrating Panchang data into your applications. Get Tithi, Nakshatra, Yoga, Karana, and auspicious timings via API.

January 7, 2026 - 15 min read

What is Panchang?

Panchang (Panchangam) is the Hindu calendar system that tracks five (pancha) elements (anga) of time. It's essential for determining auspicious dates, festival timings, and daily rituals.

The Five Elements

1. Tithi (Lunar Day)

30 tithis in a lunar month, based on Moon-Sun angle

2. Nakshatra (Lunar Mansion)

27 nakshatras, Moon's position in the zodiac

3. Yoga (Sun-Moon Combination)

27 yogas, sum of Sun and Moon longitudes

4. Karana (Half-Tithi)

11 karanas, half of each tithi

5. Vara (Weekday)

7 varas, each ruled by a planet

Get Daily Panchang

// Get complete panchang for a date and location
const response = await fetch('https://api.vedika.io/v2/astrology/panchang', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Bearer YOUR_API_KEY'
    },
    body: JSON.stringify({
        datetime: '2026-03-23T12:00:00',
        latitude: 28.6139,
        longitude: 77.2090,
        timezone: '+05:30',
        include: 'sunrise'
    })
});

const panchang = await response.json();

// Response (trimmed; the full response also carries interpretation text for each element):
// {
//     "success": true,
//     "data": {
//         "tithi": {
//             "name": "Panchami",
//             "paksha": { "id": 1, "name": "Shukla" }
//         },
//         "nakshatra": { "name": "Krittika" },
//         "yoga": { "name": "Saubhagya", "quality": "Auspicious" },
//         "karana": { "name": "Bava" },
//         "vaara": { "name": "Somavara" },
//         "masa": { "name": "Chaitra" },
//         "ritu": { "name": "Vasanta" },
//         "sunrise": {
//             "sunrise": "2026-03-23T06:12:00+05:30",
//             "sunset": "2026-03-23T18:34:00+05:30",
//             "moonrise": "2026-03-23T09:40:00+05:30",
//             "moonset": "2026-03-23T23:55:00+05:30"
//         }
//     },
//     "billing": { "charged": 0.0045, "currency": "USD" }
// }

Rahu Kaal & Inauspicious Times

import requests

API = 'https://api.vedika.io'
HEADERS = {'Authorization': 'Bearer YOUR_API_KEY'}

def get_inauspicious_times(lat, lng, timezone='Asia/Kolkata'):
    params = {'latitude': lat, 'longitude': lng, 'timezone': timezone}

    # Each endpoint answers for the current day at the location
    rahu = requests.get(f'{API}/v2/astrology/rahu-kaal', headers=HEADERS, params=params).json()['data']
    yamaghanta = requests.get(f'{API}/v2/astrology/yamaghanta', headers=HEADERS, params=params).json()['data']['yamaghanta']
    gulika = requests.get(f'{API}/v2/astrology/gulika-kaal', headers=HEADERS, params=params).json()['data']

    # Times are ISO 8601 in UTC (a trailing Z); rahu-kaal and gulika-kaal also carry is_day
    print(f"Rahu Kaal: {rahu['start']} - {rahu['end']}")
    print(f"Yamaghanta: {yamaghanta['start_time']} - {yamaghanta['end_time']}")
    print(f"Gulika Kaal: {gulika['start']} - {gulika['end']}")

    return rahu, yamaghanta, gulika

# Example
times = get_inauspicious_times(28.6139, 77.2090)

# Related endpoints:
# - rahu-kaal: Time to avoid important activities
# - yamaghanta: Another inauspicious period
# - gulika-kaal: Third inauspicious period
# - abhijit-muhurta: Most auspicious time of day (same /v2/astrology/ prefix)

Choghadiya (Auspicious Periods)

// Get Choghadiya for the day
const params = new URLSearchParams({
    latitude: '28.6139',
    longitude: '77.2090',
    timezone: 'Asia/Kolkata'
});
const choghadiyaResponse = await fetch(`https://api.vedika.io/v2/astrology/choghadiya?${params}`, {
    headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
});

const choghadiya = await choghadiyaResponse.json();

// Response (trimmed):
// {
//     "success": true,
//     "data": {
//         "date": "2026-06-14",
//         "day": [
//             {"name": "Amrit", "type": "good", "start": "06:21", "end": "07:54"},
//             {"name": "Kaal", "type": "bad", "start": "07:54", "end": "09:27"},
//             ... the remaining day periods
//         ],
//         "night": [
//             {"name": "Shubh", "type": "good", "start": "18:33", "end": "20:00"},
//             ... the remaining night periods
//         ]
//     }
// }

Festival Dates

// Get upcoming Hindu festivals (a window of 1-90 days, default 30)
const festivalsResponse = await fetch('https://api.vedika.io/v2/astrology/festivals/upcoming?from=2026-06-14&days=30', {
    headers: {'Authorization': 'Bearer YOUR_API_KEY'}
});

const festivals = await festivalsResponse.json();

// Response (trimmed):
// {
//     "success": true,
//     "data": {
//         "from": "2026-06-14",
//         "days": 30,
//         "festivals": [
//             {
//                 "name": "Jagannath Rath Yatra",
//                 "date": "2026-06-26",
//                 "type": "major",
//                 "region": "pan-india",
//                 "description": "..."
//             }
//             ... more festivals in the window
//         ]
//     }
// }

Build a Panchang Widget

// React component for Panchang widget
function PanchangWidget({ latitude, longitude }) {
    const [panchang, setPanchang] = useState(null);

    useEffect(() => {
        async function fetchPanchang() {
            const response = await fetch('https://api.vedika.io/v2/astrology/panchang', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                    'Authorization': `Bearer ${process.env.VEDIKA_API_KEY}`
                },
                body: JSON.stringify({
                    datetime: new Date().toISOString().slice(0, 19),
                    latitude,
                    longitude,
                    timezone: '+00:00',
                    include: 'sunrise'
                })
            });
            const body = await response.json();
            setPanchang(body.data);
        }
        fetchPanchang();
    }, [latitude, longitude]);

    if (!panchang) return <div>Loading...</div>;

    return (
        <div className="panchang-widget">
            <h3>Today's Panchang</h3>
            <p>Tithi: {panchang.tithi.name} ({panchang.tithi.paksha.name})</p>
            <p>Nakshatra: {panchang.nakshatra.name}</p>
            <p>Yoga: {panchang.yoga.name}</p>
            <p>Sunrise: {panchang.sunrise.sunrise}</p>
        </div>
    );
}

Add Panchang to Your App

Vedika API provides accurate Panchang calculations for any location worldwide. Support for all regional variations and 30 languages.

Get API Key