首页 开发文档 智能起名

智能起名

中文人名生成。按姓氏、性别与风格(古典/现代/诗意)从对应字库组合出名字,支持单字名与双字名,返回名字、完整姓名、拼音与笔画数。本接口仅做文字组合与音形义的常规考量,不涉及生辰八字、五行、五格剖象等命理内容,也不做姓名打分,结果仅供娱乐与灵感参考。

请求信息
请求地址 https://cx4.cn/openApi/content/naming 复制
请求方式 GET / POST
接口标识 content_naming
鉴权方式 必须
四种方式任选其一:Header「X-Api-Key」/ Header「Authorization: Bearer 你的key」/ URL 参数「?key=你的key」/ POST 参数「key」
请求参数
参数名 类型 必填 说明 示例
surname string 是 姓氏,支持复姓 李
gender string 否 male 男孩 / female 女孩,也接受 m / f / 男 / 女 male
count int 否 生成数量,1-20 3
style string 否 classic 古典 / modern 现代 / poetic 诗意 classic
length int 否 名字字数:1 单字名 / 2 双字名 2
返回参数

下表字段位于返回结构的 data 内;外层 code / message 为全平台统一格式,不在此重复列出。

参数名 类型 说明 示例
ok bool 是否成功 true
surname string 姓氏 李
gender string 性别 male
style string 风格 classic
count int 生成数量 3
list array 名字明细,含名字、全名、拼音与笔画数 []
note string 说明 仅供娱乐参考,不具备命理意义
返回示例

成功

{
    "code": 200,
    "message": "操作成功",
    "data": {
        "ok": true,
        "surname": "李",
        "gender": "男",
        "style": "classic",
        "count": 3,
        "list": [
            {
                "name": "和礼",
                "full": "李和礼",
                "gender": "男",
                "style": "classic",
                "pinyin": "hé lǐ",
                "strokes": 13
            },
            {
                "name": "义邦",
                "full": "李义邦",
                "gender": "男",
                "style": "classic",
                "pinyin": "yì bānɡ",
                "strokes": 9
            },
            {
                "name": "勇伟",
                "full": "李勇伟",
                "gender": "男",
                "style": "classic",
                "pinyin": "yǒnɡ wěi",
                "strokes": 15
            }
        ],
        "note": "名字生成基于寓意字库随机组合,仅供参考;不含五格、八字、吉凶等算命内容"
    }
}

失败

{
    "code": 400,
    "message": "请提供姓氏",
    "data": null
}
平台通用状态码
状态码 说明
200调用成功
400缺少必填参数或参数格式有误
401密钥缺失或无效
402余额不足,请充值后重试
403未开通该接口,请在本页开通后调用
404接口不存在或已下架
429触发限流,请稍后重试
500接口调用失败(已扣款的会自动退款)
调用示例

cURL 复制

curl -X POST "https://cx4.cn/openApi/content/naming" -H "X-Api-Key: 你的SecretKey" -d "surname=李&gender=male&count=3&style=classic&length=2"

JavaScript 复制

fetch('https://cx4.cn/openApi/content/naming', {
  method: 'POST',
  headers: {
    'X-Api-Key': '你的SecretKey',
    'Content-Type': 'application/x-www-form-urlencoded'
  },
  body: 'surname=李&gender=male&count=3&style=classic&length=2'
})
.then(res => res.json())
.then(data => console.log(data));

PHP 复制

post('https://cx4.cn/openApi/content/naming', [
    'headers' => ['X-Api-Key' => '你的SecretKey'],
    'form_params' => ['surname' => '李', 'gender' => 'male', 'count' => '3', 'style' => 'classic', 'length' => '2'],
]);
echo $response->getBody();

Java 复制

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://cx4.cn/openApi/content/naming"))
    .header("X-Api-Key", "你的SecretKey")
    .header("Content-Type", "application/x-www-form-urlencoded")
    .POST(HttpRequest.BodyPublishers.ofString("surname=李&gender=male&count=3&style=classic&length=2"))
    .build();
HttpResponse response = client.send(
        request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());

Python 复制

import requests

res = requests.post('https://cx4.cn/openApi/content/naming',
    headers={'X-Api-Key': '你的SecretKey'},
    data={'surname': '李', 'gender': 'male', 'count': '3', 'style': 'classic', 'length': '2'})
print(res.json())
在线测试 (使用你的密钥真实调用,计费与正常调用一致)

登录后可在线测试: 立即登录

计费说明

¥0.0010

每次调用


每日免费额度:100 次

累计调用:6 次


快速上手

1. 注册并完成邮箱验证:立即注册

2. 登录后复制 Secret Key:去登录

3. 点击右侧「开通接口」按钮

4. 用下方「在线测试」一键体验,或复制下方示例代码直接调用