如果你在搜索 AstroSage API,通常是想做三类产品之一:
- 一个回答出生盘问题的 astrology chat app。
- WhatsApp、Telegram、Discord 或网站 bot。
- 一整套占星平台,包含 Vedic chart、dasha、Panchang、match making、horoscope 和 compatibility。
FreeAstroAPI 与 AstroSage 没有关联。对开发者有价值的是架构思路:我们的 Vedic 和 astrology endpoints 返回生产级结构化结果,覆盖面适合构建 AstroSage-like 用户体验。
换句话说,不要让 LLM 编造 chart math。API 负责确定性占星数据,AI 层负责把这些数据讲清楚。
为什么 AstroSage-like app 需要结构化占星数据
如果 bot 从 prompt 里尝试计算所有东西,占星聊天产品很容易出错。模型可能语气自信,但 ascendant、Moon Nakshatra、Vimshottari dasha、Panchang 或 compatibility 细节是错的。
更适合生产的做法:
- 解析用户城市、timezone、latitude 和 longitude。
- 调用 chart、dasha、Panchang、transit 或 compatibility endpoints。
- 把结构化响应作为 source of truth 保存。
- 让 chat model 只解释 API 返回的数据。
- 保留内部引用,知道答案来自哪个 endpoint payload。
这样 app 有智能助理的体验,计算仍然确定、可重复。
AstroSage-style bot 的核心 endpoints
| Use case | Endpoint |
|---|---|
| Resolve city input | GET /api/v2/geo/search |
| Generate a Vedic birth chart | POST /api/v2/vedic/chart |
| Generate full Vedic data in one request | POST /api/v2/vedic/calculate |
| Get Vimshottari dasha periods | POST /api/v2/vedic/dasha |
| Get dasha facts for AI interpretation | POST /api/v1/vedic/dasha/insights |
| Build Gochar timeline features | POST /api/v2/vedic/gochar/timeline |
| Turn Gochar into AI-ready facts | POST /api/v2/vedic/gochar/timeline/insights |
| Detect yogas | POST /api/v2/vedic/yogas |
| Calculate Shadbala and Ashtakavarga | POST /api/v2/vedic/strength |
| Generate divisional charts | POST /api/v2/vedic/vargas |
| Generate Panchang | POST /api/v2/vedic/panchang |
| Match two people from birth details | POST /api/v2/vedic/match |
| Run compatibility from birth details or Moon details | POST /api/v2/vedic/compatibility |
需要 onboarding payload 时,用 POST /api/v2/vedic/calculate。某个聊天回合只问一个问题时,用更专门的 endpoint,比如 “What dasha am I in?” 或 “Is today good for starting something?”。
推荐 MCP chat pipeline
如果你的 app 是 AI agent,优先使用 Hosted MCP 或自己的 tool-calling 层,而不是把每个 endpoint 硬塞进 prompt。
流程:
- 分析用户问题,判断需要哪个占星事实。
- 检查需要的 JSON 是否已在 cache 中。
- 没有 cache 时,选择正确 MCP tool 或 API endpoint。
- 用用户保存的出生数据和当前问题上下文调用工具。
- 用 endpoint、input hash、user id 和 timestamp 缓存原始 JSON。
- 给 AI 用户问题和相关 JSON。
- 要求 AI 只根据 JSON 写最终回答,不补编缺失事实。
第一轮 AI 更像 router,不直接回答用户:
{
"intent": "current_dasha_question",
"needs_tool": true,
"tool": "vedic_dasha",
"cache_key": "user_123:vedic_dasha:2026-04-24:lahiri",
"reason": "The user asked which dasha is active today."
}然后 backend 执行 tool call,保存 JSON,再做第二轮 AI:
User question:
{question}
Tool JSON:
{cached_or_fresh_json}
Instruction:
Answer only from the Tool JSON. If the JSON does not contain the requested fact, say what additional tool or birth detail is needed.这比让模型在一轮里判断、计算、解释都可靠。
Cache 策略
按 user、endpoint、normalized input、date 或 date range 缓存。
| Data type | Suggested cache behavior |
|---|---|
| Birth chart, vargas, yogas, strength | 除非出生数据变化,否则永久缓存。 |
| Dasha timeline | 永久缓存,但按新的 reference date 重新判断 active selection。 |
| Panchang, daily horoscope, today pillars | 按日期和地点缓存。 |
| Gochar or transit timeline | 按 date range、planets 和 settings 缓存。 |
| Compatibility or match | 按两个用户 profiles 和 relationship settings 缓存。 |
始终保存完整原始 JSON。可以另外保存小的 "facts" object 用于检索,但原始响应对调试和答案审计很重要。
Follow-up 处理
后续消息要先复用上下文,再考虑新 tool call。
| Follow-up | What to do |
|---|---|
| "Why is that?" | 复用前一个 JSON,把证据解释得更清楚。 |
| "What about tomorrow?" | 保持同一 birth profile,调用明天相关的 date-sensitive endpoint。 |
| "And for my partner?" | 如果 partner 数据缺失先询问,已有则调用 compatibility。 |
| "Show me the chart" | 调用 chart rendering endpoint 或用缓存 chart data 渲染 UI。 |
| "Explain it more simply" | 不调用新占星 endpoint,只把同一回答改简单。 |
| "Use Western astrology instead" | 明确切换系统,调用对应 Western endpoint。 |
把 conversation memory、cached astrology facts 和 fresh tool calls 分开,后续对话会稳定很多。
可组合的公共 endpoints
Vedic astrology endpoints
| Method | Path | Use |
|---|---|---|
POST | /api/v2/vedic/chart | Vedic D1 chart with ascendant, planets, houses, Nakshatra context, and metadata. |
POST | /api/v2/vedic/calculate | Full Vedic bundle with optional vargas, dasha, yogas, Panchang, Shadbala, and Ashtakavarga. |
POST | /api/v2/vedic/dasha | Calibrated Vimshottari dasha timeline and active periods. |
POST | /api/v1/vedic/dasha/insights | AI-ready dasha fact extraction. |
POST | /api/v2/vedic/gochar/timeline | Vedic transit and Gochar timeline windows. |
POST | /api/v2/vedic/gochar/timeline/insights | Gochar facts for search, RAG, and chat interpretation. |
POST | /api/v2/vedic/yogas | Yoga detection with evidence and strength. |
POST | /api/v2/vedic/strength | Shadbala, Sarvashtakavarga, Bhinnashtakavarga, and strength data. |
POST | /api/v2/vedic/vargas | Divisional charts such as D1, D9, D10, D30, and D60. |
POST | /api/v2/vedic/panchang | Tithi, Nakshatra, Yoga, Karana, weekday, Rahu Kalam, sunrise, and sunset. |
POST | /api/v2/vedic/match | Birth-detail compatibility matching. |
POST | /api/v2/vedic/compatibility | Compatibility from birth details or manual Moon details. |
Western astrology endpoints
| Method | Path | Use |
|---|---|---|
POST | /api/v1/natal/calculate | 计算 Western natal chart,并可创建 report job。 |
GET | /api/v1/natal/report/{job_id} | 轮询生成中的 psychological report。 |
POST | /api/v1/western/natal/insights | 为 AI products 输出机器可读 natal facts。 |
POST | /api/v1/western/natal/insights/index-documents | 为 natal facts 生成 search-index documents。 |
POST | /api/v1/transits/calculate | 计算 transit chart。 |
POST | /api/v1/western/transits/timeline | 长时间范围的 transit-to-natal timeline。 |
POST | /api/v1/western/transits/timeline/index-documents | 为 transit timeline 生成 search-index documents。 |
POST | /api/v1/western/transits/insights | 更高层的 transit insight windows。 |
POST | /api/v1/western/transits/search | 在长窗口中搜索精确 transit passes。 |
POST | /api/v1/western/synastry | 完整 western synastry。 |
POST | /api/v1/western/synastry/simplified | 更轻量的 synastry payload。 |
POST | /api/v1/western/synastry/summary | Synastry summary scoring。 |
POST | /api/v1/western/synastrycards | 适合移动端的 synastry card output。 |
POST | /api/v1/western/synastry/horoscope | Daily 或 timing-aware relationship horoscope。 |
POST | /api/v1/western/solar/calculate | 计算 solar return。 |
POST | /api/v1/western/returns/calculate | 通用 planetary return calculation。 |
POST | /api/v1/western/profections/annual | Annual profection timing。 |
POST | /api/v1/western/progressions/secondary | Secondary progressions。 |
POST | /api/v1/western/progressions/converse-secondary | Converse secondary progressions。 |
POST | /api/v1/western/progressions/tertiary | Tertiary progressions。 |
POST | /api/v1/western/progressions/quotidian | Quotidian progressions。 |
POST | /api/v1/western/progressions/quaternary | Quaternary progressions。 |
POST | /api/v1/western/progressions/{system}/exact-ingresses | 为 progression systems 搜索精确 ingress。 |
POST | /api/v1/western/progressions/{system}/exact-aspects | 为 progression systems 搜索精确 aspect。 |
POST | /api/v1/western/progressions/{system}/calendar | 输出 progression calendar。 |
Chart rendering and visual endpoints
| Method | Path | Use |
|---|---|---|
POST | /api/v1/natal/chart/ | 渲染 natal chart SVG 或 PNG。 |
POST | /api/v1/natal/chart/transits | 渲染 natal plus transit chart。 |
POST | /api/v1/natal/chart/composite | 渲染 composite relationship chart。 |
POST | /api/v1/natal/chart/synastry | 渲染 synastry chart。 |
POST | /api/v1/svg/kerykeion | Kerykeion-compatible SVG rendering。 |
Astrocartography endpoints
| Method | Path | Use |
|---|---|---|
POST | /api/v1/western/astrocartography/lines | 地图用 planetary line geometry。 |
POST | /api/v1/western/astrocartography/parans | Paran geometry 和 crossing bands。 |
POST | /api/v1/western/astrocartography/recommendations | Ranked place recommendations。 |
POST | /api/v1/western/astrocartography/city-check | 为某个城市打分。 |
POST | /api/v1/western/astrocartography/relocation | Relocated chart 和 angular context。 |
Horoscope and simple sign endpoints
| Method | Path | Use |
|---|---|---|
GET | /api/v1/horoscope/daily/sign | 单个 sign 的 daily horoscope。 |
GET | /api/v1/horoscope/daily/bulk | 所有 signs 的 daily horoscopes。 |
POST | /api/v1/horoscope/daily/personal | 从 birth data 生成 personalized daily horoscope。 |
GET | /api/v2/horoscope/daily/sign | V2 sign horoscope。 |
POST | /api/v2/horoscope/daily/personal | V2 personalized horoscope。 |
POST | /api/v3/horoscope/daily/personal | 最新 personalized horoscope generation route。 |
POST | /api/v1/western/signs/sun | 计算 Sun sign。 |
POST | /api/v1/western/signs/moon | 计算 Moon sign。 |
POST | /api/v1/western/signs/rising | 计算 rising sign。 |
POST | /api/v1/western/signs/midheaven | 计算 Midheaven sign。 |
Chinese astrology endpoints
| Method | Path | Use |
|---|---|---|
POST | /api/v1/chinese/bazi | BaZi Four Pillars。 |
POST | /api/v1/chinese/bazi/flow | Annual and monthly BaZi flow。 |
GET | /api/v1/chinese/bazi/dictionary | BaZi interaction and star dictionary。 |
GET | /api/v1/chinese/today | 当前时刻的 pillars。 |
POST | /api/v1/chinese/bazi/time-correction | True solar time correction。 |
POST | /api/v1/chinese/bazi/synastry | BaZi compatibility。 |
POST | /api/v1/chinese/bazi/lifespan | Neijing life curve。 |
POST | /api/v1/chinese/bazi/health | Constitution and health tendencies。 |
Utility and platform endpoints
| Method | Path | Use |
|---|---|---|
GET | /api/v2/geo/search | Authenticated city search。 |
GET | /api/v1/geo/search | Legacy city search。 |
POST | /api/v1/ephemeris/calculate | POST ephemeris calculation。 |
GET | /api/v1/ephemeris | Query-string ephemeris calculation。 |
GET | /api/v1/moon/phase | Moon phase、zodiac、visuals 和 interpretation。 |
GET | /api/v1/moon/month | Monthly Moon phase timeline。 |
POST | /api/v1/ai/generate | Atomic AI report generation。 |
GET | /mcp | Hosted MCP endpoint。 |
POST | /mcp | Hosted MCP tool calls。 |
POST | /api/v1/auth/keys | 创建 API key。 |
GET | /api/v1/auth/keys | 列出 API keys。 |
DELETE | /api/v1/auth/keys/{key_id} | 删除 API key。 |
GET | /api/v1/auth/logs | 获取 API usage logs。 |
GET | /api/v1/billing/plans | 列出 billing plans。 |
POST | /api/v1/billing/checkout | 创建 checkout session。 |
POST | /api/v1/billing/portal | 创建 customer portal session。 |
POST | /api/v1/contact | 发送 contact message。 |
POST | /api/v1/contact/suggestion | 发送 product suggestion。 |
逐步构建 chat app
Step 1: collect birth data once
Onboarding form 应收集:
- Name
- Date of birth
- Time of birth
- Birth city
- Latitude and longitude when available
- Timezone, or
AUTO
生产环境中,坐标比城市名可靠,因为很多城市同名。用 city search 帮用户选对地点。
curl -G "https://api.freeastroapi.com/api/v2/geo/search" \
-H "x-api-key: YOUR_API_KEY" \
--data-urlencode "q=Mumbai" \
--data-urlencode "country=IN" \
--data-urlencode "limit=5"Step 2: create the user's core Vedic profile
onboarding 后调用 full calculate endpoint,把响应作为用户 astrology profile 保存。
curl -X POST "https://api.freeastroapi.com/api/v2/vedic/calculate" \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"year": 1994,
"month": 8,
"day": 11,
"hour": 6,
"minute": 42,
"city": "Mumbai",
"lat": 19.0760,
"lng": 72.8777,
"tz_str": "AUTO",
"ayanamsha": "lahiri",
"vargas": [1, 9, 10],
"include_yogas": true,
"include_panchang": true,
"include_shadbala": true,
"include_ashtakavarga": true,
"dasha_levels": 3
}'这个响应足以回答 Lagna、Moon Nakshatra、当前 dasha、career yogas、D9 和婚姻等常见问题。
Step 3: route each user question
不要每条消息都调用所有 endpoints。先分类 intent。
| User asks | API call |
|---|---|
| "Tell me about my birth chart" | Use stored /api/v2/vedic/calculate data. |
| "What dasha am I in?" | POST /api/v2/vedic/dasha or stored dasha data. |
| "What is happening this month?" | POST /api/v2/vedic/gochar/timeline/insights. |
| "Is today auspicious?" | POST /api/v2/vedic/panchang. |
| "Are we compatible?" | POST /api/v2/vedic/match or /api/v2/vedic/compatibility. |
| "Make me a daily horoscope" | POST /api/v3/horoscope/daily/personal. |
| "Show my chart wheel" | POST /api/v1/natal/chart/ or a Vedic table UI built from /api/v2/vedic/chart. |
这样可以控制延迟和成本。
Step 4: pass structured facts into the LLM
Prompt 应告诉 LLM 解释 API payload,不要重新计算。
You are an astrology assistant for a Vedic astrology app.
Use only the structured API facts below.
Do not invent planetary positions, dashas, Nakshatras, yogas, or compatibility scores.
If the needed fact is missing, ask for the missing input or say that this endpoint was not called.
User question:
{user_message}
FreeAstroAPI facts:
{json_from_relevant_endpoint}Step 5: add memory without changing the chart
- Permanent facts: birth data, chart positions, dasha timeline, vargas, Panchang at birth.
- Session memory: preferred language, tone, current goal, relationship context, recent questions.
- Fresh facts: today's Panchang, current dasha, current Gochar, daily horoscope.
这样可以避免 assistant 把之前的解释当成新的 chart fact。
Step 6: build safe answer templates
每个聊天答案最好有固定形状:
- 直接回答,一两句话。
- 来自 API payload 的证据。
- 实用解释。
- 可选的下一步问题或动作。
You are currently in Moon Mahadasha and Saturn Antardasha.
The API dasha payload shows Moon as the active Mahadasha lord and Saturn as the active sub-period lord for the selected reference date.
This usually focuses the reading on emotional security, home, responsibility, and long-term discipline.
If you want, I can compare this dasha with your current Gochar timeline.建议 app 架构
在 frontend 和 FreeAstroAPI 之间放一个小 backend。
User interface
-> Your backend chat route
-> Intent classifier
-> FreeAstroAPI endpoint call
-> Structured payload store
-> LLM response generation
-> Chat answer with endpoint-backed facts不要把 API key 暴露到 browser JavaScript。x-api-key 保留在服务器端。
Minimal Node.js server example
const API_BASE = "https://api.freeastroapi.com";
async function getVedicProfile(birthData: Record<string, unknown>) {
const response = await fetch(`${API_BASE}/api/v2/vedic/calculate`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-api-key": process.env.FREEASTROAPI_KEY || "",
},
body: JSON.stringify({
...birthData,
tz_str: "AUTO",
ayanamsha: "lahiri",
vargas: [1, 9, 10],
include_yogas: true,
include_panchang: true,
include_shadbala: true,
include_ashtakavarga: true,
dasha_levels: 3,
}),
});
if (!response.ok) {
throw new Error(`FreeAstroAPI request failed: ${response.status}`);
}
return response.json();
}SEO content strategy
如果公开发布 app,可以围绕真实搜索意图建立页面:
- "AstroSage API alternative"
- "Vedic astrology API"
- "Kundli API for developers"
- "Dasha API"
- "Panchang API"
- "Astrology chatbot API"
- "Build an astrology bot"
每个页面都应该解释具体功能、展示 live example、列出使用的 endpoint,并链接到文档。
常见错误
- 不要让 LLM 从原始出生数据计算 chart。
- 不要忽略 timezone 和历史地点处理。
- 不要每条消息都调用昂贵 endpoints。
- 不要混用 Western 和 Vedic 概念而不标注系统。
- 不要把生成解释当成确定性 chart data。
- 不要只存最终文本。也要存 API payload。
开始构建
FreeAstroAPI 提供 Vedic charts、dasha、Panchang、compatibility、Gochar、horoscopes、Western charts、synastry、moon data 和 chart rendering 的计算层。
先接入 Vedic calculate endpoint,再添加 dasha 和 Panchang intents,之后扩展到 compatibility、Gochar 和 daily horoscope。