🕓 रिकॉर्ड 2026-04-14 को, अपडेट 2026-05-09 को। TS / Python / PHP SDK अब public registries पर हैं -
@astroway/sdk(npm),astroway(PyPI),astroway/sdk(Packagist). विवरण परिवर्तन लॉग।
तू एक ज्योतिषीय एप्लिकेशन बनाना चाहता है। कहाँ से शुरू करे? इस गाइड में - समाधान और कोड: API चयन से लेकर कार्यशील प्रोडक्ट के डिप्लॉय तक।
आर्किटेक्चर प्रश्न
Section titled “आर्किटेक्चर प्रश्न”कोड लिखने से पहले, तय कर: क्लाइंट पर गणना या सर्वर पर?
क्लाइंट (उदाहरण के लिए, Swiss Ephemeris WASM ब्राउज़र में):
- फायदे: अनुरोध पर कोई लागत नहीं, ऑफलाइन काम करता है, पूर्ण नियंत्रण
- नुकसान: प्रत्येक उपयोगकर्ता के लिए ~2 MB WASM, जटिल लाइसेंसिंग (Swiss Ephemeris का व्यावसायिक उपयोग सीमित है), तू स्वयं गणना कोड का रखरखाव करता है
सर्वर API (AstroWay, Prokerala आदि):
- फायदे: क्लाइंट निर्भरताएँ नहीं, छोटा बंडल, मोबाइल पर तेज, लाइसेंसिंग दर्द नहीं
- नुकसान: अनुरोध पर क्रेडिट लागत, “कोल्ड” अनुरोधों में देरी
अधिकांश एप्लिकेशनों के लिए सर्वर API जीतता है। मोबाइल उपयोगकर्ता 2 MB WASM का इंतजार नहीं करेंगे; लाइसेंसिंग नुन्सेंस से निपटना नहीं चाहिए; और आधुनिक API समान अनुरोधों को मुफ्त में कैश करते हैं (AstroWay 5-मिनट का कैश X-Cache: HIT हेडर के साथ बनाता है)।
API चयन
Section titled “API चयन”क्या महत्वपूर्ण है:
- सटीकता: Swiss Ephemeris को “इंजन के नीचे” खोज (±1 कोणीय सेकंड)। यदि API सीधे यह नहीं बताता - पूछ।
- कवरेज: नताल + सिनास्ट्रि + ट्रांज़िट: न्यूनतम। प्रोग्रेशन और रिटर्न - अगला स्तर। दुर्लभ तकनीकें (रेक्टिफिकेशन, Human Design) - यह एक अंतरकर्ता है।
- SDK की गुणवत्ता: टाइप्ड TypeScript और Python SDK घंटे बचाते हैं।
- टैरिफ मॉडल: credit-based मिश्रित लोड पर per-request से बेहतर स्केल करता है।
इस ट्यूटोरियल के लिए हम AstroWay API लेंगे, क्योंकि इसमें सभी चार चीजें हैं (777 एंडपॉइंट, Swiss Ephemeris, टाइप्ड SDK, credit-based)।
चरण 1: बैकएंड सेटअप
Section titled “चरण 1: बैकएंड सेटअप”कभी भी ज्योतिषीय API को सीधे ब्राउज़र से न बुलाओ - तेरा API-की लीक हो जाएगा। हमेशा अपने बैकएंड के माध्यम से कॉल करो।
mkdir my-astrology-appcd my-astrology-appnpm init -ynpm install express @astroway/sdk zodnpm install -D typescript @types/express @types/node tsxफ़ाइल src/server.ts बनाओ:
import express from 'express';import { Astroway } from '@astroway/sdk';import { z } from 'zod';
const app = express();app.use(express.json());
const client = new Astroway({ apiKey: process.env.ASTROWAY_API_KEY!,});
const BirthInput = z.object({ date: z.string(), time: z.string(), timezoneOffset: z.number(), latitude: z.number(), longitude: z.number(),});
app.post('/api/chart', async (req, res) => { const parsed = BirthInput.safeParse(req.body); if (!parsed.success) return res.status(400).json({ error: parsed.error });
try { const chart = await client.chart.compute({ ...parsed.data, houseSystem: 'P', }); res.json(chart); } catch (err) { res.status(500).json({ error: String(err) }); }});
app.listen(3000, () => console.log('http://localhost:3000'));चलाओ:
ASTROWAY_API_KEY=aw_test_... npx tsx src/server.tscurl से जांचें:
curl -X POST http://localhost:3000/api/chart \ -H "Content-Type: application/json" \ -d '{"date":"1990-07-14","time":"14:30:00","timezoneOffset":3,"latitude":50.4501,"longitude":30.5234}'तुम्हें पूरी JSON-नताल चार्ट मिलती है।
चरण 2: फ्रंटएंड
Section titled “चरण 2: फ्रंटएंड”कोई भी फ्रेमवर्क चलेगा। उदाहरण के लिए - React एक साधारण फ़ॉर्म के साथ:
import { useState } from 'react';
type Chart = { planets: { name: string; longitude: number; isRetrograde: boolean }[]; aspects: { planet1: string; planet2: string; type: { name: string }; orb: number }[];};
// Planets come with ecliptic longitude, not a sign: the sign is that longitude// divided by 30. Work it out on your side, it is cheaper than another call.const SIGNS = ['Aries', 'Taurus', 'Gemini', 'Cancer', 'Leo', 'Virgo', 'Libra', 'Scorpio', 'Sagittarius', 'Capricorn', 'Aquarius', 'Pisces'];const signOf = (longitude: number) => SIGNS[Math.floor(longitude / 30) % 12];
export function NatalForm() { const [chart, setChart] = useState<Chart | null>(null);
async function handleSubmit(formData: FormData) { const body = Object.fromEntries(formData.entries()); const res = await fetch('/api/chart', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ date: body.date, time: body.time + ':00', timezoneOffset: Number(body.tz), latitude: Number(body.lat), longitude: Number(body.lng), }), }); setChart(await res.json()); }
return ( <div> <form action={handleSubmit}> <input name="date" type="date" required /> <input name="time" type="time" required /> <input name="tz" type="number" placeholder="Timezone offset (e.g. 3)" required /> <input name="lat" type="number" step="0.0001" placeholder="Latitude" required /> <input name="lng" type="number" step="0.0001" placeholder="Longitude" required /> <button>Build chart</button> </form>
{chart && ( <div> <h2>Planets</h2> <ul> {chart.planets.map(p => ( <li key={p.name}>{p.name}: {signOf(p.longitude)} {(p.longitude % 30).toFixed(2)}°{p.isRetrograde ? ' R' : ''}</li> ))} </ul> <h2>Aspects</h2> <ul> {chart.aspects.map((a, i) => ( <li key={i}>{a.planet1} {a.type.name} {a.planet2} (orb {a.orb.toFixed(2)}°)</li> ))} </ul> </div> )} </div> );}चरण 3: सिनास्ट्रि
Section titled “चरण 3: सिनास्ट्रि”संगतता - अगली स्पष्ट फीचर। src/server.ts में जोड़ो:
const SynastryInput = z.object({ chart1: BirthInput, chart2: BirthInput,});
app.post('/api/synastry', async (req, res) => { const parsed = SynastryInput.safeParse(req.body); if (!parsed.success) return res.status(400).json({ error: parsed.error });
const result = await client.synastry.compute(parsed.data); res.json({ score: result.compatibility.score, label: result.compatibility.label, aspects: result.crossAspects, });});बस। एक एंडपॉइंट, कॉल पर 50 क्रेडिट, स्कोर 0–100 और क्रॉस-अस्पेक्ट्स लौटाता है।
चरण 4: दैनिक राशिफल
Section titled “चरण 4: दैनिक राशिफल”कंटेंट एंगेजमेंट के लिए दैनिक राशिफल - अनिवार्य। AstroWay उन्हें ट्रांज़िट डेटा से जनरेट करता है:
// The daily horoscope is keyed by sign and date, not by the birth chart.const DailyInput = z.object({ sign: z.enum(['aries', 'taurus', 'gemini', 'cancer', 'leo', 'virgo', 'libra', 'scorpio', 'sagittarius', 'capricorn', 'aquarius', 'pisces']), date: z.string(),});
app.post('/api/horoscope/daily', async (req, res) => { const parsed = DailyInput.safeParse(req.body); if (!parsed.success) return res.status(400).json({ error: parsed.error });
const horoscope = await client.horoscope.daily({ ...parsed.data, language: 'uk' }); res.json({ text: horoscope.horoscope, disclaimer: horoscope.disclaimer, // must be shown in the UI! });});महत्वपूर्ण: AI-जनित कंटेंट में डिस्क्लेमर होता है, जिसे तुझे उपयोगकर्ताओं को दिखाना अनिवार्य है (Terms of Service के अनुसार)। इसे न हटाओ।
चरण 5: कैशिंग
Section titled “चरण 5: कैशिंग”दैनिक राशिफल सभी उपयोगकर्ताओं के लिए समान होते हैं जिनका जन्मदिन एक ही है और समान नताल चार्ट हैं। आक्रामक रूप से कैश करो:
import { LRUCache } from 'lru-cache';
const cache = new LRUCache<string, any>({ max: 1000, ttl: 86400 * 1000 });
app.post('/api/horoscope/daily', async (req, res) => { const key = JSON.stringify(req.body); const cached = cache.get(key); if (cached) return res.json(cached);
const horoscope = await client.horoscope.daily(req.body); cache.set(key, horoscope); res.json(horoscope);});AstroWay में भी बिल्ट-इन 5-मिनट सर्वर कैश (X-Cache: HIT) है, लेकिन दीर्घकालिक कंटेंट के लिए अपना कैश चाहिए।
चरण 6: डिप्लॉय
Section titled “चरण 6: डिप्लॉय”कोई भी प्लेटफ़ॉर्म चलेगा। तेज़ शुरुआत के लिए - Vercel या Railway:
# vercel.json{ "functions": { "src/server.ts": { "runtime": "@vercel/node" } } }प्लेटफ़ॉर्म पैनल में env ASTROWAY_API_KEY सेट करो।
बजट योजना
Section titled “बजट योजना”अगर तू यहाँ तक आया है - लॉन्च से पहले मासिक क्रेडिट उपयोग का अनुमान लगा:
credits/month = DAU × (avg_charts_per_user × 20 + avg_synastries × 50 + avg_horoscopes × 20) × 30100 DAU के लिए, प्रति उपयोगकर्ता 1 चार्ट + 1 राशिफल + 0.3 सिनास्ट्रि प्रति दिन:
100 × (20 + 20 + 0.3 × 50) × 30 = 165,000 credits/monthयह Starter योजना है $19/माह (200K क्रेडिट) के लिए।
आगे क्या
Section titled “आगे क्या”उन्नत फीचर जो बढ़ते समय जोड़ने चाहिए:
- ट्रांज़िट ओवरले:
/v1/transitsवर्तमान ग्रह स्थितियों को नताल चार्ट पर दिखाता है - प्रोग्रेशन:
/v1/progressionsमनोवैज्ञानिक विकास के लिए - Solar return:
/v1/solar-return“जन्मदिन से एक साल के लिए प्रेडिक्शन” के लिए - Human Design: Human Design API एक नया फ़ंक्शनल डोमेन खोलता है
- अस्ट्रोकार्टोग्राफी:
/v1/acgदिखाता है कि उपयोगकर्ता को कहाँ रहना चाहिए
हर फीचर को शून्य से बनाना कठिन है, लेकिन - सिर्फ एक AstroWay API कॉल से।
शुरूआत
Section titled “शुरूआत”- मुफ़्त API-की प्राप्त करो: 10 000 क्रेडिट / माह
- पूरा API रेफ़रेंस: सभी 777 एंडपॉइंट
- Birth Chart API: चार्ट एंडपॉइंट की विस्तृत डॉक्यूमेंटेशन
वही Swiss Ephemeris जो Solar Fire में है - बस 4 लाइनों के कोड में।
कार्ड के बिना मुफ्त कुंजी। पहले भुगतान तक 5,000 कॉल प्रति माह।