Panchang API - Django Integration

Get daily Panchang with Tithi, Nakshatra, Yoga, Karana, and auspicious times

Overview

Get daily Panchang with Tithi, Nakshatra, Yoga, Karana, and auspicious times

POST /v2/astrology/panchang
Pricing: $0.003 per request | Framework: Django | Auth: API Key required

Quick Start

1. Installation

pip install requests

2. Environment Setup

# .env
VEDIKA_API_KEY=your_api_key_here
Security: Never commit API keys to version control. Always use environment variables.

Complete Implementation

# panchang/views.py
import os
import requests
from django.conf import settings
from django.http import JsonResponse
from django.views.decorators.http import require_http_methods
from django.views.decorators.csrf import csrf_exempt
import json

VEDIKA_BASE_URL = 'https://vedika-api-854222120654.us-central1.run.app'

def get_panchang(params):
    """
    Get daily Panchang with Tithi, Nakshatra, Yoga, Karana, and auspicious times
    """
    headers = {
        'Content-Type': 'application/json',
        'x-api-key': settings.VEDIKA_API_KEY
    }

    try:
        response = requests.post(
            f'{VEDIKA_BASE_URL}/v2/astrology/panchang',
            json=params,
            headers=headers,
            timeout=10
        )
        response.raise_for_status()
        return response.json()
    except requests.exceptions.RequestException as e:
        raise Exception(f'Vedika API Error: {str(e)}')

@csrf_exempt
@require_http_methods(['POST'])
def panchang_view(request):
    """
    Django view for Panchang
    """
    try:
        data = json.loads(request.body)
        result = get_panchang(data)
        return JsonResponse(result, status=200)
    except Exception as e:
        return JsonResponse({'error': str(e)}, status=500)

# urls.py:
# from panchang.views import panchang_view
# urlpatterns = [
#     path('api/panchang/', panchang_view, name='panchang'),
# ]

# settings.py:
# VEDIKA_API_KEY = os.getenv('VEDIKA_API_KEY')

Request Parameters

Parameter Type Required Description
date varies Yes See API documentation
latitude varies Yes See API documentation
longitude varies Yes See API documentation
timezone varies Yes See API documentation

Error Handling

Status Code Error Solution
400 Bad Request Check request parameters and format
401 Unauthorized Verify API key is correct
402 Payment Required Insufficient balance - recharge at console.vedika.io
429 Rate Limit Exceeded Implement exponential backoff or upgrade plan
500 Server Error Retry after a few seconds

Best Practices

Response Format

{
  "success": true,
  "data": {
    // Endpoint-specific response data
  },
  "timestamp": "2026-01-07T10:30:00Z",
  "cost": 0.003
}

Related Endpoints

Birth Chart Kundli Match Dasha Periods Dosha Analysis

Other Frameworks

React Next.js Vue.js Angular Node.js Python/Flask Ruby on Rails

Support

Need help integrating this endpoint?