从用户名推断性别 · 单次请求

根据用户名判断性别

从社交账号、昵称或别名中提取一个可能的姓名,并返回带有置信度评分的预测结果。

POSThttps://api.genderapi.io/api/username

请求概览

从用户名推导出可能的姓名

GenderAPI 会在提交的用户名中查找名称信号,然后结合数据库证据、国家背景,以及在需要时的AI备用方案来预测性别。

Inputsparkling_unicorn
提取的信号Sparkling
Prediction女性 · 92%
MethodPOST
内容类型application/json
AuthenticationBearer令牌
AI选项Available
HDR

必需的HTTP头

授权请求

Content-Typeapplication/json
AuthorizationBearer YOUR_API_KEY

JSON 请求体

参数

ParameterTypeRequirementDescription
usernamestring必填项需要分析的用户名、社交账号、显示名称或昵称。
countrystring可选ISO 3166-1 alpha-2 国家代码,例如 US 或 TR,用于区域上下文。
askToAIboolean可选当为 true 时,如果提取的名称在数据库中无结果,则使用 AI 降级处理。
forceToGenderizeboolean可选当为 true 时,尝试对别名或不符合典型名称格式的输入进行预测。
askToAI

仅在提取的姓名在数据库中无结果时使用。

forceToGenderize

允许对幻想术语、品牌类别名和不寻常昵称进行尝试。

置信度很重要:对于弱或非人类姓名信号的强制结果可能不够可靠。在采取预测行动前需评估probability。

代码示例

发送用户名请求

cURL
curl -X POST "https://api.genderapi.io/api/username" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{"username":"sparkling_unicorn","country":"US","askToAI":true,"forceToGenderize":true}'
JavaScript
const response = await fetch("https://api.genderapi.io/api/username", {
  method: "POST",
  headers: { "Content-Type": "application/json", "Authorization": "Bearer YOUR_API_KEY" },
  body: JSON.stringify({ username: "sparkling_unicorn", country: "US", askToAI: true, forceToGenderize: true })
});
Python
import requests
response = requests.post(
  "https://api.genderapi.io/api/username",
  headers={"Authorization": "Bearer YOUR_API_KEY"},
  json={"username": "sparkling_unicorn", "country": "US", "askToAI": True, "forceToGenderize": True}
)
print(response.json())

200 响应

提取的信号 and prediction

JSON
{
  "status": true, "used_credits": 1, "remaining_credits": 4999,
  "expires": 1743659200, "q": "sparkling_unicorn",
  "name": "Sparkling", "gender": "female", "country": "US",
  "total_names": 9876, "probability": 92, "duration": "6ms"
}

响应字段

FieldTypeDescription
statusboolean请求是否成功完成。
used_creditsinteger本次请求消耗的信用额度。
remaining_creditsinteger请求后剩余的信用额度。
expiresinteger套餐过期时间,以 UNIX 时间戳表示。
qstring请求中提交的原始用户名。
namestring从用户名中提取的可能姓名。
genderstring | null预测值:男、女或空值。
countrystring预测所考虑的国家代码。
total_namesinteger支持该预测的样本数量。
probabilityinteger预测置信度,以百分比表示。
durationstring服务器处理时间。

将用户名视为间接信号

一个用户名可能描述一个品牌、角色或概念,而非一个人。确认提取结果是否具有意义,并为您的使用场景建立可接受的概率阈值。name一个用户名可能描述一个品牌、角色或概念,而非一个人。确认提取结果是否具有意义,并为您的使用场景建立可接受的概率阈值。

下一步指南

分析多个用户名

批量用户名请求一次请求处理多个账号标识 →邮箱单个请求从邮箱中提取姓名 →