正在启动平台

八字起名 API 接入文档baby-naming

输入父母姓氏与出生时间,基于「八字五行 + 五格数理 + 三才配置」综合评分生成高分名字候选,附寓意标签与全国重名预估。三个 action:naming(智能起名)/ duplicate(重名查询)/ bazi(八字查询)。内置 396 姓氏笔画 + 175 起名字 + 88 姓人口。

1. 基本信息

接口地址https://v1.apizero.cn/api/baby-naming
请求方法POST
分类life
提供方极数本源
计费模式免费试用
单次消耗0 积分
起步价
QPS 限制2 req/s
每日免费额度5000 次(已认证用户)
匿名每日额度3000 次(无 API Key)
VIP 免费
调用次数

2. 认证

匿名可调用:QPS 1 / 每日 30 次。登录用户:QPS 2 / 每日 50 次。

获取 API Key:登录 https://apizero.cn/account/keys

3. 请求参数

参数名类型必填说明示例
actionstringnaming(默认)/ duplicate / bazi
surnamestringnaming/duplicate 必填;姓氏(≤ 2 字)
mother_surnamestring母姓(仅 naming,可选;填写则生成双姓名)
birth_yearnumbernaming/bazi 必填;2000-21002026
birth_monthnumbernaming/bazi 必填;1-125
birth_daynumbernaming/bazi 必填;1-3110
birth_hournumber出生时辰;0-23,默认 12
genderstring性别偏好:male/female/neutral,默认 neutral
countnumber返回名字数量;1-30,默认 10
namestringduplicate 必填;要查的名字(不含姓)梓涵

4. 请求头

Header类型必填说明示例
Authorizationstring

5. 请求示例

以下 5 种语言示例都是可直接运行的,只需把 YOUR_API_KEY 替换为实际 Key。

cURL

curl -X POST "https://v1.apizero.cn/api/baby-naming" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "action": "<action>",
  "surname": "王",
  "mother_surname": "<mother_surname>",
  "birth_year": "2026",
  "birth_month": "5",
  "birth_day": "10",
  "birth_hour": "<birth_hour>",
  "gender": "<gender>",
  "count": "<count>",
  "name": "梓涵"
}'

Python

import requests

resp = requests.request(
    "POST",
    "https://v1.apizero.cn/api/baby-naming",
    headers={"X-Api-Key": "YOUR_API_KEY", "Content-Type": "application/json"},
    json={
    "action": "<action>",
    "surname": "王",
    "mother_surname": "<mother_surname>",
    "birth_year": "2026",
    "birth_month": "5",
    "birth_day": "10",
    "birth_hour": "<birth_hour>",
    "gender": "<gender>",
    "count": "<count>",
    "name": "梓涵",
},
    timeout=15,
)
resp.raise_for_status()
print(resp.json())

JavaScript (Node.js)

// Node.js 18+ / 浏览器原生 fetch
const res = await fetch("https://v1.apizero.cn/api/baby-naming", {
  method: "POST",
  headers: {
    "X-Api-Key": "YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "action": "<action>",
    "surname": "王",
    "mother_surname": "<mother_surname>",
    "birth_year": "2026",
    "birth_month": "5",
    "birth_day": "10",
    "birth_hour": "<birth_hour>",
    "gender": "<gender>",
    "count": "<count>",
    "name": "梓涵"
  }),
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
console.log(data);

Go

package main

import (
	"bytes"
	"fmt"
	"io"
	"net/http"
)

func main() {
	body := []byte(`{"action":"<action>","surname":"王","mother_surname":"<mother_surname>","birth_year":"2026","birth_month":"5","birth_day":"10","birth_hour":"<birth_hour>","gender":"<gender>","count":"<count>","name":"梓涵"}`)
	req, _ := http.NewRequest("POST", "https://v1.apizero.cn/api/baby-naming", bytes.NewBuffer(body))
	req.Header.Set("X-Api-Key", "YOUR_API_KEY")
	req.Header.Set("Content-Type", "application/json")

	resp, err := http.DefaultClient.Do(req)
	if err != nil { panic(err) }
	defer resp.Body.Close()
	out, _ := io.ReadAll(resp.Body)
	fmt.Println(string(out))
}

PHP

<?php
$payload = json_encode([
    "action" => "<action>",
    "surname" => "王",
    "mother_surname" => "<mother_surname>",
    "birth_year" => "2026",
    "birth_month" => "5",
    "birth_day" => "10",
    "birth_hour" => "<birth_hour>",
    "gender" => "<gender>",
    "count" => "<count>",
    "name" => "梓涵",
], JSON_UNESCAPED_UNICODE);

$ch = curl_init("https://v1.apizero.cn/api/baby-naming");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST  => "POST",
    CURLOPT_POSTFIELDS     => $payload,
    CURLOPT_HTTPHEADER     => [
        "X-Api-Key: YOUR_API_KEY",
        "Content-Type: application/json",
    ],
    CURLOPT_TIMEOUT        => 15,
]);
$body = curl_exec($ch);
curl_close($ch);

$data = json_decode($body, true);
print_r($data);

6. 响应字段

字段类型说明示例
bazi.八字string八字字符串
bazi.四柱array年/月/日/时四柱
bazi.日主string日主五行
wu_xing_analysisobject五行分布 / 缺失 / 建议补充
needed_wuxingarray建议补充的五行
namesarray推荐名字列表(含分数、五格、寓意、重名预估)

7. 响应示例

{
    "code": 0,
    "msg": "成功",
    "data": {
        "bazi": {
            "八字": "丙午癸巳辛未癸巳",
            "四柱": [
                "丙午",
                "癸巳",
                "辛未",
                "癸巳"
            ],
            "日主": "金"
        },
        "wu_xing_analysis": {
            "五行分布": {
                "金": 1,
                "木": 0,
                "水": 2,
                "火": 4,
                "土": 1
            },
            "五行缺失": [
                "木"
            ],
            "建议补充": [
                "木"
            ]
        },
        "needed_wuxing": [
            "木"
        ],
        "names": [
            {
                "name": "王梓森",
                "surname": "王",
                "given_name": "梓森",
                "score": 95,
                "wuge": {
                    "天格": 5,
                    "人格": 15,
                    "地格": 23,
                    "外格": 16,
                    "总格": 27
                },
                "wuge_score": 88,
                "wuxing_chars": "木+木",
                "meaning_tags": [
                    "栋梁",
                    "繁盛"
                ],
                "duplicate_rate": {
                    "estimated_count": 320,
                    "level": "较低",
                    "description": "..."
                }
            }
        ]
    },
    "request_id": "abc123"
}

8. 错误码

codestatus说明
4000参数缺失或越界(surname/birth_year/month/day/hour/count)
4029调用过快(QPS 超限)
4030今日额度用完

9. 变更日志

  • 1.0.0(2026-05-10)
    • 首次上线,支持 naming / duplicate / bazi 三种 action

常见问题

八字起名 接口怎么免费使用?

未登录用户每个 IP 每天 3000 次免费。登录用户创建 API Key 后每天 5000 次免费,超额部分按点数计费(0 点/次)。

八字起名 支持哪些调用方式?

接口使用 POST 请求。文档提供 cURL、Python、JavaScript (Node.js)、Go、PHP 五种语言的可运行示例。也可以下载 /openapi.json 导入 Postman / Insomnia / Apifox 反向生成 SDK。

调用不限额么? QPS 是多少?

本接口 QPS 限制 2 req/s,每个 API Key 每日免费 5000 次。需要更高额度可升级 VIP 套餐或联系售后提高 QPS。

这个接口跟自己直连上游有什么区别?

极数本源 作为中间层提供:统一鉴权(一个 Key 调所有接口)、统一计费(点数制)、统一限流、统一错误码、多上游自动切换。免去逐个对接上游、维护 Key、统计调用量的运维成本。