星盘解释API文档

接口说明

本接口用于根据星盘配置返回相应的解释语料。支持单个请求和批量请求(数组),可以查询行星解释、行星落入星座、行星落入宫位、行星相位等多种类型的解释内容。

基本信息

参数 值
Base URL https://chart.12sign.top
接口URL /interpretation
请求方式 POST
Content-Type application/json

请求参数

单个请求格式

参数名 类型 必选 说明
chartType string 是 星盘类型,如 "natal"(本命盘)、"composite"(组合盘)、"transit"(流年)等
fallInto object 是 查询条件对象,根据type不同包含不同的字段
fallInto.type number 是 语料类型:1=行星解释,4=行星落宫,5=行星落座,6=行星相位

fallInto 字段说明(根据type不同)

type = 1: 行星解释

参数名 类型 必选 说明
type number 是 固定值:1
planet_id number 是 行星ID(1-17)

type = 4: 行星落宫

参数名 类型 必选 说明
type number 是 固定值:4
planet_id number 是 行星ID(1-17)
house_id number 是 宫位ID(1-12)

type = 5: 行星落座

参数名 类型 必选 说明
type number 是 固定值:5
planet_id number 是 行星ID(1-17)
sign_id number 是 星座ID(1-12)

type = 6: 行星相位

参数名 类型 必选 说明
type number 是 固定值:6
planet_id1 number 是 第一个行星ID(1-17)
planet_id2 number 是 第二个行星ID(1-17)
degree number 是 相位度数:0, 30, 45, 60, 90, 120, 135, 150, 180

批量请求格式

批量请求使用数组格式,数组中每个元素都是一个单独的请求对象:

[
    {
        "chartType": "natal",
        "fallInto": {...}
    },
    {
        "chartType": "natal",
        "fallInto": {...}
    }
]

请求示例

示例1:行星解释(单个请求)

{
    "chartType": "natal",
    "fallInto": {
        "type": 1,
        "planet_id": 1
    }
}

示例2:行星落座(单个请求)

{
    "chartType": "natal",
    "fallInto": {
        "type": 5,
        "planet_id": 1,
        "sign_id": 1
    }
}

示例3:行星落宫(单个请求)

{
    "chartType": "natal",
    "fallInto": {
        "type": 4,
        "planet_id": 1,
        "house_id": 10
    }
}

示例4:行星相位(单个请求)

{
    "chartType": "natal",
    "fallInto": {
        "type": 6,
        "planet_id1": 1,
        "planet_id2": 2,
        "degree": 120
    }
}

示例5:批量请求

[
    {
        "chartType": "natal",
        "fallInto": {
            "type": 1,
            "planet_id": 1
        }
    },
    {
        "chartType": "natal",
        "fallInto": {
            "type": 5,
            "planet_id": 1,
            "sign_id": 1
        }
    },
    {
        "chartType": "natal",
        "fallInto": {
            "type": 4,
            "planet_id": 1,
            "house_id": 10
        }
    },
    {
        "chartType": "natal",
        "fallInto": {
            "type": 6,
            "planet_id1": 1,
            "planet_id2": 2,
            "degree": 120
        }
    }
]

返回参数

单个请求成功返回

参数名 类型 说明
success boolean 请求是否成功
data object 解释数据对象
data.chart_type string 星盘类型
data.type number 语料类型(1, 4, 5, 6)
data.planet_id number 行星ID(所有类型都有)
data.sign_id number 星座ID(仅type=5时返回)
data.house_id number 宫位ID(仅type=4时返回)
data.planet_id2 number 第二个行星ID(仅type=6时返回)
data.degree number 相位度数(仅type=6时返回)
data.keywords string 关键词(如果有)
data.content string 主要解释内容

单个请求失败返回

参数名 类型 说明
success boolean 固定值:false
error string 错误信息
code string 错误代码(MISSING_PARAMS, NOT_FOUND, DB_NOT_FOUND, INTERNAL_ERROR)

批量请求返回

参数名 类型 说明
success boolean 请求是否成功
data array 解释数据数组(只包含找到的结果)
total number 请求总数
found number 找到的结果数量

返回示例

示例1:行星解释返回

{
    "success": true,
    "data": {
        "chart_type": "natal",
        "type": 1,
        "planet_id": 1,
        "content": "太阳代表了你的自我、个性、意识、精神以及使个人独一无二的东西。它是你的身份和你面对世界的面孔。太阳也代表了你的创造能力和应对日常生活挑战的能力。"
    }
}

示例2:行星落座返回

{
    "success": true,
    "data": {
        "chart_type": "natal",
        "type": 5,
        "planet_id": 1,
        "sign_id": 1,
        "keywords": "勇于冒险,充满激情,超强行动力",
        "content": "你是勇往直前的野心家,有着积极进取的冒险精神,能够将心中所想及时转化为行动。你总是充满热情和活力,很容易吸引众多的追随者,是天生的领导者..."
    }
}

示例3:行星落宫返回

{
    "success": true,
    "data": {
        "chart_type": "natal",
        "type": 4,
        "planet_id": 1,
        "house_id": 10,
        "content": "你可能有强大的企图心,想要获得成就和声望,而且很可能成名。你常常想要证明自己的能力,往往成就也来得快..."
    }
}

示例4:行星相位返回

{
    "success": true,
    "data": {
        "chart_type": "natal",
        "type": 6,
        "planet_id": 1,
        "planet_id2": 2,
        "degree": 120,
        "content": "你天生善于与重要的异性相处,容易成为好爸爸、好妈妈,与家人相处得很融洽,喜欢小孩。夫妻关系稳定,彼此成为对方的寄托,容易得到美好的姻缘..."
    }
}

示例5:批量请求返回

{
    "success": true,
    "data": [
        {
            "chart_type": "natal",
            "type": 1,
            "planet_id": 1,
            "content": "太阳代表了你的自我..."
        },
        {
            "chart_type": "natal",
            "type": 5,
            "planet_id": 1,
            "sign_id": 1,
            "keywords": "勇于冒险,充满激情,超强行动力",
            "content": "你是勇往直前的野心家..."
        },
        {
            "chart_type": "natal",
            "type": 4,
            "planet_id": 1,
            "house_id": 10,
            "content": "你可能有强大的企图心..."
        }
    ],
    "total": 3,
    "found": 3
}

示例6:未找到返回

{
    "success": false,
    "error": "未找到匹配的解释语料",
    "code": "NOT_FOUND"
}

ID映射表

行星ID映射

行星名称 ID
太阳1
月亮2
水星3
金星4
火星5
木星6
土星7
天王星8
海王星9
冥王星10
北交点11
凯龙星15
莉莉丝16
谷神星17

星座ID映射

星座名称 ID
白羊1
金牛2
双子3
巨蟹4
狮子5
处女6
天秤7
天蝎8
射手9
摩羯10
水瓶11
双鱼12

宫位ID映射

宫位名称 ID
一宫1
二宫2
三宫3
四宫4
五宫5
六宫6
七宫7
八宫8
九宫9
十宫10
十一宫11
十二宫12

星盘类型(chartType)

类型名称 值
本命盘natal
组合盘composite
三限tertiary
流年transit
次限secondary
流年星盘transit_chart
太阳返照solar_return
月亮返照lunar_return
比较盘synastry

相位度数

度数 相位名称
0合相
30半六分相
45半四分相
60六分相
90四分相
120三分相
135倍四分相
150补十二分相
180对分相

Python测试代码示例

import requests
import json

# 测试行星解释
def test_planet_interpretation():
    url = "https://chart.12sign.top/interpretation"
    
    payload = {
        "chartType": "natal",
        "fallInto": {
            "type": 1,
            "planet_id": 1
        }
    }
    
    response = requests.post(url, json=payload)
    result = response.json()
    print(json.dumps(result, ensure_ascii=False, indent=2))
    return result

# 测试行星落座
def test_planet_sign():
    url = "https://chart.12sign.top/interpretation"
    
    payload = {
        "chartType": "natal",
        "fallInto": {
            "type": 5,
            "planet_id": 1,
            "sign_id": 1
        }
    }
    
    response = requests.post(url, json=payload)
    result = response.json()
    print(json.dumps(result, ensure_ascii=False, indent=2))
    return result

# 测试行星落宫
def test_planet_house():
    url = "https://chart.12sign.top/interpretation"
    
    payload = {
        "chartType": "natal",
        "fallInto": {
            "type": 4,
            "planet_id": 1,
            "house_id": 10
        }
    }
    
    response = requests.post(url, json=payload)
    result = response.json()
    print(json.dumps(result, ensure_ascii=False, indent=2))
    return result

# 测试行星相位
def test_planet_aspect():
    url = "https://chart.12sign.top/interpretation"
    
    payload = {
        "chartType": "natal",
        "fallInto": {
            "type": 6,
            "planet_id1": 1,
            "planet_id2": 2,
            "degree": 120
        }
    }
    
    response = requests.post(url, json=payload)
    result = response.json()
    print(json.dumps(result, ensure_ascii=False, indent=2))
    return result

# 测试批量请求
def test_batch_request():
    url = "https://chart.12sign.top/interpretation"
    
    payload = [
        {
            "chartType": "natal",
            "fallInto": {
                "type": 1,
                "planet_id": 1
            }
        },
        {
            "chartType": "natal",
            "fallInto": {
                "type": 5,
                "planet_id": 1,
                "sign_id": 1
            }
        },
        {
            "chartType": "natal",
            "fallInto": {
                "type": 4,
                "planet_id": 1,
                "house_id": 10
            }
        },
        {
            "chartType": "natal",
            "fallInto": {
                "type": 6,
                "planet_id1": 1,
                "planet_id2": 2,
                "degree": 120
            }
        }
    ]
    
    response = requests.post(url, json=payload)
    result = response.json()
    print(json.dumps(result, ensure_ascii=False, indent=2))
    return result

if __name__ == "__main__":
    print("测试行星解释...")
    test_planet_interpretation()
    
    print("\n测试行星落座...")
    test_planet_sign()
    
    print("\n测试行星落宫...")
    test_planet_house()
    
    print("\n测试行星相位...")
    test_planet_aspect()
    
    print("\n测试批量请求...")
    test_batch_request()

注意事项

  • 相位查询时,planet_id1 和 planet_id2 的顺序不影响查询结果(会自动匹配两个方向)
  • 批量请求时,如果某个请求未找到匹配数据,该请求不会出现在返回的 data 数组中
  • 所有ID都是数字类型
  • 相位度数必须精确匹配(不支持容差),支持的度数:0, 30, 45, 60, 90, 120, 135, 150, 180
  • 返回数据中不包含null值字段,只返回有值的字段
  • 根据type不同,返回的字段也不同:
    • type=1(行星解释):只返回 chart_type, type, planet_id, content
    • type=4(行星落宫):返回 chart_type, type, planet_id, house_id, keywords, content
    • type=5(行星落座):返回 chart_type, type, planet_id, sign_id, keywords, content
    • type=6(行星相位):返回 chart_type, type, planet_id, planet_id2, degree, content
  • 目前主要包含本命盘类型的语料,其他星盘类型的数据较少