八字排盘

正在计算... Calculating...

公历:

农历:

四柱八字 BaZi Chart

年柱 Year Pillar

月柱 Month Pillar

日柱 Day Pillar

时柱 Hour Pillar

日主 Day Master

五行分布 Five Elements Distribution

生肖星座 Zodiac

生肖 Chinese Zodiac
星座 Western Zodiac

命理要素 Destiny Elements

贵人 Nobleman

桃花 Peach Blossom

文昌 Intelligence Star

天马 Sky Horse

节气 Solar Terms

当前节气 Current Solar Term

黄历宜忌 Almanac

宜 Suitable

    忌 Avoid

      十二建除 Jian Chu

      吉神 Auspicious Gods

        凶神 Inauspicious Gods

          彭祖百忌 Peng Zu

            时辰吉凶 Hourly Fortune

            时辰 Hour 时间 Time 吉凶 Fortune

            📚 API 使用说明

            本页面提供完整的 API 文档,方便 AI 和开发者调用。

            🔌 基础信息

            Base URL: http://localhost:3002

            Content-Type: application/json

            支持跨域: 已启用 CORS

            📡 API 端点列表

            GET /api/health
            健康检查接口

            响应示例

            { "status": "ok", "message": "BaZi Calculator API is running", "version": "2.0.0" }
            POST /api/calculate
            计算八字命盘(核心接口)

            请求参数

            字段 类型 必需 约束 说明
            calendarType string solar | lunar 日历类型(阳历/农历)
            year integer 1900-2100 出生年份
            month integer 1-12 出生月份
            day integer 1-31 出生日期
            hour integer 0-23 出生小时(24小时制)
            gender string male | female 性别,默认 male
            isLeapMonth boolean false 是否闰月(农历时)

            响应示例(成功)

            { "success": true, "data": { "solarDate": { "year": 2000, "month": 1, "day": 1, "hour": 12, "formatted": "2000年4月30日 12:00" }, "lunarDate": { "year": 2000, "month": 3, "day": 7, "isLeap": false, "formatted": "2000年3月7日" }, "yearPillar": { "stem": "壬", "branch": "戌", "element": "水", "full": "壬戌" }, "monthPillar": { "stem": "甲", "branch": "辰", "element": "木", "full": "甲辰" }, "dayPillar": { "stem": "癸", "branch": "未", "element": "水", "full": "癸未" }, "hourPillar": { "stem": "戊", "branch": "午", "element": "土", "full": "戊午" }, "dayMaster": { "gan": "癸", "element": "水", "nature": "阴" }, "fiveElementsDistribution": { "木": 1, "火": 1, "土": 4, "金": 0, "水": 2 }, "zodiac": { "chineseZodiac": "狗", "westernZodiac": "金牛座" }, "huangli": { "yi": ["嫁娶", "移徙", "入宅", ...], "ji": ["祈福", "求嗣"], "jianChu": "满", "jiShen": ["天德", "月德"], "xiongShen": ["月煞", "月虚"], "pengZu": ["壬不汲水", "戌不吃犬"], "hourFortune": [ {"hour": "子", "timeRange": "23:00-01:00", "fortune": "吉"}, ... ] }, "solarTerms": [...], "nobleman": ["子", "申"], "peachBlossom": "丑", "intelligenceStar": "亥", "skyHorse": "子" } }

            响应示例(错误)

            { "success": false, "error": "Missing required fields: calendarType, year, month, day, hour are required" }
            GET /api/solar-terms/{year}
            获取指定年份的24节气

            路径参数

            参数 类型 必需 约束 说明
            year integer 1900-2100 年份

            响应示例

            { "success": true, "data": [ {"name": "立春", "date": "1990-02-04T16:00:00.000Z"}, {"name": "雨水", "date": "1990-02-19T16:00:00.000Z"}, ... ] }

            💻 代码示例

            cURL

            curl -X POST http://localhost:3002/api/calculate \
              -H "Content-Type: application/json" \
              -d "{\"calendarType\":\"solar\",\"year\":2000,\"month\":4,\"day\":30,\"hour\":12,\"gender\":\"male\"}"

            Python

            import requests
            
            response = requests.post(
                "http://localhost:3002/api/calculate",
                json={
                    "calendarType": "solar",
                    "year": 2000,
                    "month": 1,
                    "day": 1,
                    "hour": 12,
                    "gender": "male"
                }
            )
            data = response.json()
            print(data)

            ⚠️ 错误码说明

            状态码 含义 常见原因
            200 成功 请求成功处理
            400 请求参数错误 缺少必需字段、字段类型错误、超出范围
            500 服务器错误 计算异常、系统错误

            🧪 在线测试