Choghadiya API - Node.js Integration

Get daily Choghadiya muhurta times

Overview

Get daily Choghadiya muhurta times

POST /v2/astrology/choghadiya
Pricing: $0.002 per request | Framework: Node.js | Auth: API Key required

Quick Start

1. Installation

npm install axios express dotenv

2. Environment Setup

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

Complete Implementation

// choghadiya.js
const axios = require('axios');
require('dotenv').config();

const vedikaClient = axios.create({
  baseURL: 'https://vedika-api-854222120654.us-central1.run.app',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': process.env.VEDIKA_API_KEY
  },
  timeout: 10000
});

async function getChoghadiya(params) {
  try {
    const response = await vedikaClient.post('/v2/astrology/choghadiya', params);
    return response.data;
  } catch (error) {
    console.error('Vedika API Error:', error.response?.data || error.message);
    throw error;
  }
}

// Express.js route example
const express = require('express');
const router = express.Router();

router.post('/choghadiya', async (req, res) => {
  try {
    const result = await getChoghadiya(req.body);
    res.json(result);
  } catch (error) {
    res.status(error.response?.status || 500).json({
      error: error.response?.data?.error || 'Internal server error'
    });
  }
});

module.exports = { getChoghadiya, router };

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.002
}

Related Endpoints

Birth Chart Kundli Match Panchang Dasha Periods Dosha Analysis

Other Frameworks

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

Support

Need help integrating this endpoint?