How to Build a Planetary Yogas Calculator Using Vedic Astrology API
Integrate 300+ planetary yoga combinations into your app. Learn to detect Raj Yoga, Gajakesari, and other astrological patterns with code examples.
How to Build a Planetary Yogas Calculator Using Vedic Astrology API
Planetary yogas are special combinations in Vedic astrology that indicate significant life patterns - wealth, fame, spiritual growth, or challenges. This guide shows you how to integrate 300+ yoga combinations into your astrology application using the RoxyAPI Vedic Astrology API.
What Are Planetary Yogas?
Yogas are specific planetary alignments in a birth chart that produce distinct results. Famous examples include:
- Gajakesari Yoga - Jupiter in kendra from Moon (wealth, wisdom)
- Raja Yoga - Planets exalted in kendras (power, authority)
- Neecha Bhanga Raja Yoga - Debilitated planet getting cancelled (rise after fall)
- Kemadruma Yoga - Moon isolated with no planets in adjacent houses (struggles)
- Budha-Aditya Yoga - Sun and Mercury together (intelligence, communication)
The RoxyAPI provides 300+ yoga definitions you can use to analyze birth charts without implementing complex detection logic yourself.
API Overview
The Vedic Astrology API offers two yoga endpoints:
GET /yoga - List all 300+ yogas (id + name only)
GET /yoga/:id - Get detailed yoga info (description, results, quality)
This two-step approach is optimized for:
- Building searchable yoga browsers
- Progressive data loading (list first, details on-demand)
- Client-side filtering by name or category
- Reducing payload size for mobile apps
Quick Start: Fetch All Yogas
// List all available yogas
const response = await fetch('https://roxyapi.com/api/v2/vedic-astrology/yoga', {
headers: { 'X-API-Key': 'your_api_key_here' }
});
const data = await response.json();
console.log(data.total); // 300
console.log(data.yogas[0]); // { id: 'bheri', name: 'Bheri Yoga' }
Response structure:
{
"yogas": [
{ "id": "gajakesari", "name": "Gajakesari Yoga" },
{ "id": "raja", "name": "Raja Yoga" },
{ "id": "budha-aditya", "name": "Budha-Aditya Yoga" }
],
"total": 300
}
Get Yoga Details
// Fetch specific yoga information
const yogaId = 'gajakesari';
const response = await fetch(
`https://roxyapi.com/api/v2/vedic-astrology/yoga/${yogaId}`,
{ headers: { 'X-API-Key': 'your_api_key_here' } }
);
const yoga = await response.json();
Response:
{
"id": "gajakesari",
"name": "Gajakesari Yoga",
"description": "Jupiter in kendra from Moon",
"result": "You may have a number of relatives. Generous personality, cares about people. Destined for authority positions like magistrate. Lasting reputation even after death.",
"quality": "Positive"
}
Quality values: "Positive", "Negative", or "Both"
Building a Yoga Browser Component
React example with search and filtering:
import { useState, useEffect } from 'react';
function YogaBrowser() {
const [yogas, setYogas] = useState([]);
const [search, setSearch] = useState('');
const [selected, setSelected] = useState(null);
useEffect(() => {
fetch('https://roxyapi.com/api/v2/vedic-astrology/yoga', {
headers: { 'X-API-Key': process.env.ROXYAPI_KEY }
})
.then(res => res.json())
.then(data => setYogas(data.yogas));
}, []);
const fetchDetails = async (id) => {
const res = await fetch(
`https://roxyapi.com/api/v2/vedic-astrology/yoga/${id}`,
{ headers: { 'X-API-Key': process.env.ROXYAPI_KEY } }
);
setSelected(await res.json());
};
const filtered = yogas.filter(y =>
y.name.toLowerCase().includes(search.toLowerCase())
);
return (
<div>
<input
placeholder="Search yogas..."
value={search}
onChange={e => setSearch(e.target.value)}
/>
<ul>
{filtered.map(yoga => (
<li key={yoga.id} onClick={() => fetchDetails(yoga.id)}>
{yoga.name}
</li>
))}
</ul>
{selected && (
<div>
<h2>{selected.name}</h2>
<p><strong>Formation:</strong> {selected.description}</p>
<p><strong>Quality:</strong> {selected.quality}</p>
<p>{selected.result}</p>
</div>
)}
</div>
);
}
Detection Logic (Manual Implementation)
While the API provides yoga definitions, detection requires birth chart analysis. Here's how to detect Gajakesari Yoga:
async function detectGajakesariYoga(birthData) {
// 1. Get planetary positions
const chart = await fetch(
'https://roxyapi.com/api/v2/vedic-astrology/birth-chart',
{
method: 'POST',
headers: {
'X-API-Key': 'your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify(birthData)
}
).then(r => r.json());
// 2. Extract Jupiter and Moon positions
const jupiter = chart.meta.Jupiter;
const moon = chart.meta.Moon;
// 3. Calculate house difference (kendra = 1, 4, 7, 10)
const rashis = ['aries', 'taurus', 'gemini', 'cancer', 'leo',
'virgo', 'libra', 'scorpio', 'sagittarius',
'capricorn', 'aquarius', 'pisces'];
const jupiterIndex = rashis.indexOf(jupiter.rashi.toLowerCase());
const moonIndex = rashis.indexOf(moon.rashi.toLowerCase());
const houseDiff = Math.abs(jupiterIndex - moonIndex);
const isKendra = [0, 3, 6, 9].includes(houseDiff);
// 4. Fetch yoga description if present
if (isKendra) {
const yogaDetails = await fetch(
'https://roxyapi.com/api/v2/vedic-astrology/yoga/gajakesari',
{ headers: { 'X-API-Key': 'your_api_key' } }
).then(r => r.json());
return {
present: true,
yoga: yogaDetails
};
}
return { present: false };
}
Common Yoga Categories
Organize yogas by category for better UX:
const YOGA_CATEGORIES = {
wealth: ['dhana', 'gajakesari', 'lakshmi'],
power: ['raja', 'amala', 'kahala'],
intelligence: ['budha-aditya', 'saraswathi', 'bharathi'],
spiritual: ['sanyasa', 'pravrajya', 'moksha'],
challenging: ['daridra', 'duryoga', 'kemadruma']
};
// Filter yogas by category
function getYogasByCategory(allYogas, category) {
const ids = YOGA_CATEGORIES[category];
return allYogas.filter(y => ids.includes(y.id));
}
Caching Strategy
Cache yoga list (rarely changes) but fetch details on-demand:
// Cache yoga list for 30 days
const CACHE_KEY = 'vedic_yogas_list';
const CACHE_DURATION = 30 * 24 * 60 * 60 * 1000;
async function getCachedYogas() {
const cached = localStorage.getItem(CACHE_KEY);
if (cached) {
const { data, timestamp } = JSON.parse(cached);
if (Date.now() - timestamp < CACHE_DURATION) {
return data;
}
}
const response = await fetch(
'https://roxyapi.com/api/v2/vedic-astrology/yoga',
{ headers: { 'X-API-Key': process.env.ROXYAPI_KEY } }
);
const data = await response.json();
localStorage.setItem(CACHE_KEY, JSON.stringify({
data: data.yogas,
timestamp: Date.now()
}));
return data.yogas;
}
Production Features
1. Yoga Detection Service
class YogaDetector {
constructor(apiKey) {
this.apiKey = apiKey;
this.baseUrl = 'https://roxyapi.com/api/v2/vedic-astrology';
}
async detectAll(birthData) {
const chart = await this.getBirthChart(birthData);
const detectedYogas = [];
// Implement detection logic for key yogas
if (this.hasGajakesari(chart)) {
detectedYogas.push(await this.getYogaDetails('gajakesari'));
}
if (this.hasRajaYoga(chart)) {
detectedYogas.push(await this.getYogaDetails('raja'));
}
return detectedYogas;
}
hasGajakesari(chart) {
// Check Jupiter-Moon kendra relationship
const jupiter = chart.meta.Jupiter;
const moon = chart.meta.Moon;
return this.isKendra(jupiter.rashi, moon.rashi);
}
hasRajaYoga(chart) {
// Check for exalted planets in kendras
const kendraRashis = this.getKendraRashis(chart);
return kendraRashis.some(rashi =>
this.hasExaltedPlanet(chart, rashi)
);
}
async getYogaDetails(id) {
const res = await fetch(`${this.baseUrl}/yoga/${id}`, {
headers: { 'X-API-Key': this.apiKey }
});
return res.json();
}
}
2. Yoga Report Generator
async function generateYogaReport(birthData) {
const detector = new YogaDetector(process.env.ROXYAPI_KEY);
const yogas = await detector.detectAll(birthData);
// Group by quality
const positive = yogas.filter(y => y.quality === 'Positive');
const negative = yogas.filter(y => y.quality === 'Negative');
const mixed = yogas.filter(y => y.quality === 'Both');
return {
totalDetected: yogas.length,
strengthScore: positive.length - negative.length,
yogas: { positive, negative, mixed }
};
}
3. Mobile-Optimized List
// React Native yoga list with lazy loading
function YogaListScreen() {
const [yogas, setYogas] = useState([]);
const [page, setPage] = useState(1);
const loadMore = () => {
const start = (page - 1) * 20;
const batch = allYogas.slice(start, start + 20);
setYogas([...yogas, ...batch]);
setPage(page + 1);
};
return (
<FlatList
data={yogas}
renderItem={({ item }) => <YogaCard yoga={item} />}
onEndReached={loadMore}
onEndReachedThreshold={0.5}
/>
);
}
Use Cases
- Astrology Learning Apps - Browse and study yoga combinations
- Kundli Analysis Tools - Auto-detect yogas in birth charts
- Matrimonial Platforms - Highlight positive yogas in profiles
- Daily Horoscopes - Mention transit-activated yogas
- Consultation Software - Quick reference for astrologers
Best Practices
✅ Cache the yoga list - It rarely changes
✅ Fetch details on-demand - Reduces initial load
✅ Implement search - 300 yogas need filtering
✅ Group by category - Wealth, power, spiritual, etc.
✅ Show quality badges - Color-code positive/negative
✅ Link to birth chart - Show which planets form the yoga
✅ Progressive loading - Paginate for mobile apps
Limitations & Future Plans
Current API:
- Provides yoga definitions only
- Manual detection logic required
- No automatic chart analysis
Coming Soon:
- POST endpoint for automatic detection
- Strength scoring for each yoga
- Transit-based yoga activation dates
- Remedial measures for negative yogas
Conclusion
The RoxyAPI Vedic Astrology API gives you instant access to 300+ planetary yoga combinations without maintaining a complex yoga database. The two-endpoint design (list + details) optimizes for performance while providing deep information when needed.
Next Steps:
- Implement detection logic for top 20 yogas
- Build categorized yoga browser
- Add yoga explanations to birth chart reports
- Create yoga notification system for transits
Ready to add planetary yogas to your app? Get your API key and explore the complete Vedic Astrology API documentation.