Skip to content

星盘渲染

生成精美的 SVG 和 PNG 星盘图像。

SVG 星盘

使用查询参数生成 SVG 本命盘:

bash
curl -X GET "https://api.astroapi.cloud/api/chart/image.svg?width=800&height=800&dateTime=1990-06-15T14:30&location.longitude=-0.1278&location.latitude=51.5074&location.timezone=Europe/London" \
  -H "X-Api-Key: your-api-key"

PNG 星盘

转换为 PNG 格式:

bash
curl -X GET "https://api.astroapi.cloud/api/chart/image.png?width=800&height=800&dateTime=1990-06-15T14:30&location.longitude=-0.1278&location.latitude=51.5074&location.timezone=Europe/London" \
  -H "X-Api-Key: your-api-key" \
  --output chart.png

星盘类型

端点描述
/api/chart/image.svgSVG 格式本命盘
/api/chart/image.pngPNG 格式本命盘
transit.* 参数的 /api/chart/image.svg行运双轮盘
/api/chart/composite.svg复合盘(中点)
/api/chart/composite.pngPNG 格式复合盘

行运双轮盘

添加行运参数以渲染包含本命(内轮)和行运(外轮)的双轮盘:

bash
curl -X GET "https://api.astroapi.cloud/api/chart/image.svg?width=800&height=800&dateTime=1990-06-15T14:30&location.longitude=-0.1278&location.latitude=51.5074&location.timezone=Europe/London&transit.dateTime=2024-01-15T12:00&transit.timezone=Europe/London" \
  -H "X-Api-Key: your-api-key"

行运参数

参数必填描述
transit.dateTime行运日期/时间(YYYY-MM-DDTHH:mm)
transit.timezone行运时区
transit.longitude行运地点经度(默认使用本命地点)
transit.latitude行运地点纬度(默认使用本命地点)

复合盘

生成显示两张本命盘中点的复合盘:

bash
curl -X GET "https://api.astroapi.cloud/api/chart/composite.svg?width=800&height=800&person1.dateTime=1990-06-15T14:30&person1.timezone=Europe/London&person1.longitude=-0.1278&person1.latitude=51.5074&person2.dateTime=1988-03-22T09:15&person2.timezone=Europe/Paris&person2.longitude=2.3522&person2.latitude=48.8566" \
  -H "X-Api-Key: your-api-key"

查询参数

本命盘参数

参数必填描述
width星盘宽度(像素)
height星盘高度(像素)
dateTime出生日期/时间(YYYY-MM-DDTHH:mm)
location.longitude出生地点经度
location.latitude出生地点纬度
location.timezone出生地点时区(IANA 格式)

复合盘参数

参数必填描述
width星盘宽度(像素)
height星盘高度(像素)
person1.dateTime第一人出生日期/时间
person1.timezone第一人时区
person1.longitude第一人经度
person1.latitude第一人纬度
person2.dateTime第二人出生日期/时间
person2.timezone第二人时区
person2.longitude第二人经度
person2.latitude第二人纬度

响应头

星盘端点返回适当的内容类型:

  • SVG:image/svg+xml
  • PNG:image/png

嵌入星盘

在 HTML 中直接使用返回的 SVG:

html
<div class="chart-container">
  <!-- SVG content from API -->
</div>

或将其作为带数据 URL 的图像来源:

html
<img src="data:image/svg+xml;base64,..." alt="Natal Chart" />

Chart2 — 下一代星盘

AstroAPI 提供支持主题和动画的下一代星盘渲染引擎。

端点

端点描述所需模块
/api/chart2/natal.svg本命盘(SVG)module:natal-calc
/api/chart2/natal.png本命盘(PNG)module:natal-calc
/api/chart2/transit.svg行运双轮盘(SVG)module:transit-calc
/api/chart2/transit.png行运双轮盘(PNG)module:transit-calc
/api/chart2/synastry.svg合盘(SVG)module:synastry-calc
/api/chart2/synastry.png合盘(PNG)module:synastry-calc
/api/chart2/composite.svg复合盘(SVG)module:synastry-calc
/api/chart2/composite.png复合盘(PNG)module:synastry-calc
/api/chart2/animated-transit.svg动态行运(SVG)module:transit-calc

基本用法

bash
curl -X GET "https://api.astroapi.cloud/api/chart2/natal.svg?width=800&height=800&dateTime=1990-06-15T14:30&location.longitude=4.89&location.latitude=52.37&location.timezone=Europe/Amsterdam&theme=dark" \
  -H "X-Api-Key: your-api-key"

主题预设

主题描述
default经典白色背景搭配彩色元素
classic传统占星外观
dark现代深色主题搭配鲜艳色彩
minimal简洁,视觉噪音较少
colorful鲜艳的行星配色
nextgen现代风格,带弯曲相位线、光晕效果和渐变
vintage古朴羊皮纸/手稿风格,采用棕褐色调
neon赛博朋克风,黑色背景上的霓虹亮色
pastel柔和、平静的粉彩色调
print高对比度黑白,针对打印优化

主题覆盖

通过查询参数自定义单个主题属性:

参数描述
theme.background背景颜色(十六进制)
theme.foreground前景颜色(十六进制)
theme.strokeOnly仅描边模式(true/false)
theme.symbolScale符号缩放因子
theme.showDegrees显示度数标签(true/false)
theme.showHouseNumbers显示宫位编号(true/false)
theme.showRuler显示标尺(true/false)
theme.signBackgroundOpacity星座背景透明度(0-1)

合盘与复合盘

bash
curl -X GET "https://api.astroapi.cloud/api/chart2/synastry.svg?width=800&height=800&person1.dateTime=1990-06-15T14:30&person1.timezone=Europe/Amsterdam&person1.longitude=4.89&person1.latitude=52.37&person2.dateTime=1992-03-20T09:15&person2.timezone=Europe/London&person2.longitude=-0.12&person2.latitude=51.50" \
  -H "X-Api-Key: your-api-key"

动态行运

生成随时间变化的动态行运 SVG:

bash
curl -X GET "https://api.astroapi.cloud/api/chart2/animated-transit.svg?width=800&height=800&dateTime=1990-06-15T14:30&location.longitude=4.89&location.latitude=52.37&location.timezone=Europe/Amsterdam&transit.dateTime=2025-01-01T12:00&transit.timezone=Europe/Amsterdam&target.dateTime=2025-12-31T23:59&animation.duration=3000" \
  -H "X-Api-Key: your-api-key"
参数描述
target.dateTime动画结束日期
animation.duration动画持续时间(毫秒)
animation.easing缓动函数(默认:easeInOut)
animation.loop循环动画(默认:false)

AstroAPI Documentation