次限推运盘API文档

接口说明

本接口用于生成次限推运盘,需要提供本命盘数据和推运目标时间/地点信息,计算并绘制次限推运星盘图。次限推运是一种重要的预测技术,每一天代表人生的一年。

基本信息

请求参数

参数名 类型 必选 说明
chart_type string 固定值:"progression_sec"
natal_data.datetime string 本命盘出生日期时间,格式:YYYY-MM-DD HH:MM:SS 或 YYYY-MM-DD HH:MM
natal_data.lat number 本命盘出生地纬度
natal_data.lon number 本命盘出生地经度
natal_data.tz string 本命盘时区,格式:数字字符串,如"8.0"表示UTC+8
target_data.datetime string 推运目标日期时间,格式:YYYY-MM-DD HH:MM:SS 或 YYYY-MM-DD HH:MM
target_data.lat number 推运地点纬度
target_data.lon number 推运地点经度
target_data.tz string 推运地点时区,格式:数字字符串,如"8.0"表示UTC+8
house_system string 宫位系统,默认为占星安宫(P)
use_chinese_font boolean 是否使用中文字体,默认false
include_svg Boolean 是否包含SVG图像,默认false

请求示例

{
        "chart_type": "progression_sec",
        "natal_data": {
        "datetime": "1990-01-01 12:00:00",
        "lat": 39.9042,
        "lon": 116.4074,
        "tz": "8.0"
        },
        "target_data": {
        "datetime": "2024-03-01 12:00:00",
        "lat": 31.2304,
        "lon": 121.4737,
        "tz": "8.0"
        },
        "house_system": "P",
        "use_chinese_font": true,
						"include_svg":true,
        }

返回参数

参数名 类型 说明
success boolean 请求是否成功
data object 星盘数据,包含行星位置、宫位等信息
svg string 星盘SVG图形数据

返回示例

{
        "success": true,
        "data": {
        "chart_type": "progression_sec",
        "planets": [
            {"name": "sun", "degree": 280.5, ...},
            {"name": "moon", "degree": 125.3, ...},
            ...
        ],
        "houses": [
            {"house": 1, "degree": 45.2, ...},
            {"house": 2, "degree": 75.8, ...},
            ...
        ]
        },
        "svg": "..."
        }

Python测试代码示例

import requests
import json
import os
from datetime import datetime, timedelta

class ProgressionSecAPITest:
    def __init__(self, base_url="http://chart.12sign.top"):
        self.base_url = base_url
        self.endpoint = f"{base_url}/onechart"
        
        # 创建输出目录
        self.output_dir = "test_chart_outputs"
        if not os.path.exists(self.output_dir):
            os.makedirs(self.output_dir)
    
    def test_progression_sec_chart(self):
        """测试次限推运盘API"""
        payload = {
            "chart_type": "progression_sec",
            "natal_data": {
                "datetime": "1990-01-01 12:00:00",
                "lat": 39.9042,
                "lon": 116.4074,
                "tz": "8.0"
            },
            "target_data": {
                "datetime": "2024-01-01 12:00:00",
                "lat": 39.9042,
                "lon": 116.4074,
                "tz": "8.0"
            },
            "house_system": "P",
            "use_chinese_font": True
        }
        
        try:
            print(f"正在测试次限推运盘API: {self.endpoint}")
            print(f"请求数据: {json.dumps(payload, indent=2, ensure_ascii=False)}")
            
            response = requests.post(
                self.endpoint,
                json=payload,
                headers={'Content-Type': 'application/json'}
            )
            
            print(f"响应状态码: {response.status_code}")
            
            if response.status_code == 200:
                result = response.json()
                print("次限推运盘API测试成功!")
                print(f"返回数据包含: {list(result.keys())}")
                print("完整的返回数据:")
                print(result)
                # 保存SVG文件
                if 'svg' in result and result['svg']:
                    svg_filename = os.path.join(self.output_dir, 'progression_sec_chart_test.svg')
                    with open(svg_filename, 'w', encoding='utf-8') as f:
                        f.write(result['svg'])
                    print(f"SVG文件已保存: {svg_filename}")
                else:
                    print("警告: 响应中没有SVG数据")
                
                return result
            else:
                print(f"API请求失败: {response.status_code}")
                print(f"错误信息: {response.text}")
                return None
                
        except requests.exceptions.RequestException as e:
            print(f"请求错误: {e}")
            return None
        except json.JSONDecodeError as e:
            print(f"JSON解析错误: {e}")
            return None
        except Exception as e:
            print(f"未知错误: {e}")
            return None

def test_progression_sec_api():
    """简化的次限推运盘API测试函数"""
    import requests
    import json
    import os
    
    # API配置
    base_url = "http://chart.12sign.top"
    api_url = f"{base_url}/onechart"
    
    # 测试数据
    payload = {
        "chart_type": "progression_sec",
        "natal_data": {
            "datetime": "1990-01-01 12:00:00",
            "lat": 39.9042,
            "lon": 116.4074,
            "tz": "8.0"
        },
        "target_data": {
            "datetime": "2024-01-01 12:00:00",
            "lat": 39.9042,
            "lon": 116.4074,
            "tz": "8.0"
        },
        "house_system": "P",
        "use_chinese_font": True
    }
    
    try:
        print("正在测试次限推运盘API...")
        response = requests.post(api_url, json=payload, headers={'Content-Type': 'application/json'})
        print(f"响应状态码: {response.status_code}")
        
        if response.status_code == 200:
            data = response.json()
            print("次限推运盘API测试成功!")
            print(f"返回数据包含: {list(data.keys())}")
            
            # 保存SVG文件
            if 'svg' in data and data['svg']:
                os.makedirs('test_outputs', exist_ok=True)
                with open('test_outputs/progression_sec_test.svg', 'w', encoding='utf-8') as f:
                    f.write(data['svg'])
                print("SVG文件已保存: test_outputs/progression_sec_test.svg")
            
            return data
        else:
            print(f"API请求失败: {response.status_code}")
            print(f"错误信息: {response.text}")
            return None
            
    except Exception as e:
        print(f"请求出错: {e}")
        return None

if __name__ == "__main__":
    test_progression_sec_api()

注意事项

  • natal_data为本命盘数据,target_data为次限推运的目标时间和地点数据
  • 次限推运使用"一天等于一年"的原理,系统会自动计算对应的推运时间
  • 推运地点可以与出生地点不同,适用于迁移地的次限推运盘计算
  • 日期时间格式必须为:YYYY-MM-DD HH:MM:SS
  • 经纬度使用小数格式,东经北纬为正,西经南纬为负
  • 时区格式为数字字符串,如"8.0"表示UTC+8,"-5.0"表示UTC-5
  • 本API已通过完整测试,确保功能正常
  • 返回的SVG字段可能为null,请在使用前检查