Overview
Detect Mangal Dosha (Mars affliction) in birth chart
POST /v2/astrology/mangal-dosha
Pricing: $0.004 per request | Framework: Next.js | Auth: API Key required
Quick Start
1. Installation
npm install axios
# or
yarn add axios
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
// app/api/vedika/dosha/route.ts
import { NextResponse } from 'next/server';
import axios from 'axios';
export async function POST(request: Request) {
try {
const body = await request.json();
const response = await axios.post(
'https://vedika-api-854222120654.us-central1.run.app/v2/astrology/mangal-dosha',
body,
{
headers: {
'Content-Type': 'application/json',
'x-api-key': process.env.VEDIKA_API_KEY!
}
}
);
return NextResponse.json(response.data);
} catch (error: any) {
return NextResponse.json(
{ error: error.response?.data?.error || 'Internal server error' },
{ status: error.response?.status || 500 }
);
}
}
// components/DoshaAnalysis.tsx
'use client';
import { useState } from 'react';
export default function DoshaAnalysis() {
const [data, setData] = useState(null);
const [loading, setLoading] = useState(false);
const fetchDoshaAnalysis = async (params: any) => {
setLoading(true);
try {
const response = await fetch('/api/vedika/dosha', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(params)
});
const result = await response.json();
setData(result.data);
} finally {
setLoading(false);
}
};
return {/* Your UI */};
}
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
datetime |
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
- Secure API Keys: Always use environment variables, never hardcode
- Error Handling: Implement comprehensive error handling for all status codes
- Caching: Cache responses when appropriate to reduce costs
- Timeout: Set reasonable timeout values (10-30 seconds)
- Rate Limiting: Implement client-side rate limiting to avoid 429 errors
- Validation: Validate input parameters before making API calls
- Logging: Log API errors for debugging and monitoring
- Testing: Use sandbox endpoints for development and testing
Response Format
{
"success": true,
"data": {
// Endpoint-specific response data
},
"timestamp": "2026-01-07T10:30:00Z",
"cost": 0.004
}
Related Endpoints
Other Frameworks
Support
Need help integrating this endpoint?
- Email: support@vedika.io
- Documentation: vedika.io/docs
- API Console: console.vedika.io
- GitHub Examples: github.com/vedika-io/examples