Skip to content

内容与解读

访问全面的占星解读文本库。

概述

内容 API 提供以下解读文本的访问权限:

  • 行星在星座中的位置
  • 行星在宫位中的位置
  • 行星之间的相位
  • 行运解读
  • 合盘解读

列出内容

按星盘类型和内容类型列出内容:

bash
curl -X GET "https://api.astroapi.cloud/api/content/natal/planet-in-sign?page[size]=20" \
  -H "X-Api-Key: your-api-key"

内容类型

类型描述
planet-in-sign行星在黄道星座中的位置
planet-in-house行星在宫位中的位置
aspect两颗行星之间的相位
transit行运解读
synastry合盘相位解读

星盘类型

类型描述
natal本命盘解读
transit行运解读
synastry合盘解读
composite复合盘解读
chinese-horoscope中国星座解读
chinese-forecast中国年度运势解读
numerology数字学解读
moon-sun月亮和太阳解读
moon-calendar月亮日历解读
retrograde逆行周期解读
progression二次推运解读
horoscope通用星座运势解读

按 ID 获取

bash
curl -X GET "https://api.astroapi.cloud/api/content/natal/planet-in-sign/abc123" \
  -H "X-Api-Key: your-api-key"

响应

json
{
  "data": {
    "type": "content",
    "id": "abc123",
    "attributes": {
      "title": "Sun in Gemini",
      "body": "With your Sun in Gemini, you possess a quick, curious mind...",
      "urn": "urn:content:1:natal:planet-in-sign:sun:gemini:en"
    }
  }
}

Markdown 格式

内容响应中的 body 字段以 Markdown 格式呈现。这支持丰富的文本格式,包括标题、粗体/斜体文本、列表等。

如果您想在应用程序中以 HTML 形式显示内容,需要使用 Markdown 解析库将其转换为 HTML。

JavaScript/TypeScript

javascript
import { marked } from "marked";

const html = marked.parse(content.body);

或使用 markdown-it

javascript
import MarkdownIt from "markdown-it";

const md = new MarkdownIt();
const html = md.render(content.body);

Python

python
import markdown

html = markdown.markdown(content["body"])

PHP

php
use League\CommonMark\CommonMarkConverter;

$converter = new CommonMarkConverter();
$html = $converter->convert($content['body']);

按标题过滤

使用 filter 查询参数按标题搜索内容:

bash
curl -X GET "https://api.astroapi.cloud/api/content/natal/planet-in-sign?filter=title:*sun*" \
  -H "X-Api-Key: your-api-key"

在计算中包含解读

推荐的获取解读文本方式是在计算请求中直接使用 includeText 参数:

bash
curl -X POST "https://api.astroapi.cloud/api/calc/natal" \
  -H "X-Api-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "dateTime": "1990-06-15T14:30",
    "location": {
      "latitude": 51.5074,
      "longitude": -0.1278,
      "timezone": "Europe/London"
    },
    "includeText": true,
    "language": "en"
  }'

这将在您的计算响应中为每个位置和相位附加解读文本。

分页

使用 JSON:API 分页参数:

bash
curl -X GET "https://api.astroapi.cloud/api/content/natal/planet-in-sign?page[size]=10&page[number]=0" \
  -H "X-Api-Key: your-api-key"

响应包含 links.next URL,指向下一页结果。

AstroAPI Documentation