Quickstart Guide
Your first API call in 5 minutes
Prerequisites
- Node.js 18+ installed
- Vedika API key (manage your key)
- Basic JavaScript/TypeScript knowledge
1
Install the SDK
npm install @vedika-io/sdk
2
Initialize the Client
const { VedikaClient, VedikaAPIError } = require('@vedika-io/sdk');
try {
const vedika = new VedikaClient({
apiKey: process.env.VEDIKA_API_KEY
});
console.log('Client constructed locally; key validity is not checked.');
} catch (error) {
if (error instanceof VedikaAPIError) {
console.error(error.message, error.statusCode);
} else {
console.error(error.message);
}
process.exitCode = 1;
}
The V1 chart call returns { chartData: { data: ... }, metadata: ... }. Keep the complete response; do not flatten billing metadata. The current SDK chart declaration is broader than this wire contract.
3
Make Your First Call
Let's get a birth chart for someone born on May 15, 1990 in New Delhi:
async function readBirthChart(vedika) {
const result = await vedika.getBirthChart({
datetime: '1990-05-15T10:30:00+05:30',
latitude: 28.6139,
longitude: 77.2090,
timezone: '+05:30'
});
const chart = result.chartData.data;
console.log('Ascendant:', chart.ascendant);
console.log('Metadata:', result.metadata);
for (const planet of chart.planets) {
console.log(planet.name + ': ' + planet.sign + ', longitude ' + planet.degree);
}
return result;
}
Complete Working Example
// quickstart.cjs
const { VedikaClient } = require('@vedika-io/sdk');
async function main() {
// Initialize client
const vedika = new VedikaClient({
apiKey: process.env.VEDIKA_API_KEY
});
// Birth details
const birthDetails = {
datetime: '1990-05-15T10:30:00+05:30',
latitude: 28.6139,
longitude: 77.2090,
timezone: 'Asia/Kolkata'
};
try {
// 1. Get Birth Chart
console.log('Fetching birth chart...');
const chart = await vedika.getBirthChart(birthDetails);
console.log('Birth Chart:', {
ascendant: chart.chartData.data.ascendant,
metadata: chart.metadata
});
// 2. Get Today's Panchang
console.log('\nFetching today\'s panchang...');
const panchang = await vedika.getPanchang({
date: new Date().toISOString().split('T')[0],
latitude: 28.6139,
longitude: 77.2090
});
console.log('Panchang:', panchang);
// 3. Get Dasha Periods
console.log('\nFetching dasha periods...');
const dasha = await vedika.getDashas(birthDetails);
console.log('Dasha periods:', dasha);
// 4. AI-Powered Question
console.log('\nAsking AI about career...');
const response = await vedika.askQuestion({
question: 'What are the career prospects for this person?',
birthDetails
});
console.log('Response:', response.response);
} catch (error) {
console.error('Error:', error.message);
}
}
main();
Run the Example
# VEDIKA_API_KEY must already be securely configured for this server.
export VEDIKA_API_KEY
node quickstart.cjs
Illustrative structure only; values come from your actual response.
Fetching birth chart...
Birth Chart: { ascendant: { ... }, metadata: { ... } }
Fetching today's panchang...
Panchang: { ...returned envelope... }
Fetching dasha periods...
Dasha periods: { ...returned data... }
Asking AI about career...
Response: <returned response>
SDK Methods Overview
| Method | Description | Pricing |
|---|---|---|
getBirthChart() |
Generate complete birth chart with planetary positions | $0.02 |
getPanchang() |
Get daily panchang (tithi, nakshatra, yoga, karana) | $0.01 |
checkCompatibility() |
Match two horoscopes for compatibility | $0.05 |
getDashas() |
Calculate Vimshottari Dasha periods | $0.03 |
analyzeDoshas() |
Check for Mangal Dosha | $0.03 |
askQuestion() |
AI-powered astrology questions | $0.01-0.05 |