请求概览
从邮箱地址到性别预测
GenderAPI 分析邮箱地址中 @ 之前的部分,提取最可能的名字并据此预测性别。如果您知道用户所在地区,请提供国家/地区信息。
01输入邮箱
→michael.smith@example.com02提取姓名
→Michael03性别预测
male · 97%方法POST
内容类型application/json
身份验证Bearer token
额度消耗1 次查询
HDR
必需的 HTTP 请求头
为请求授权
Content-Typeapplication/jsonAuthorizationBearer YOUR_API_KEYJSON 请求体
参数
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
email | string | 必填 | 需要分析的电子邮箱地址。GenderAPI 会先提取最可能的名字,再进行性别预测。 |
country | string | 可选 | ISO 3166-1 alpha-2 国家/地区代码,例如 CN 或 US,用于提供地域信息。 |
askToAI | boolean | 可选 | 设为 true 时,如果提取出的姓名在数据库中没有结果,则启用 AI 回退。 |
AI 回退
askToAI 会在姓名提取后判断,并且仅当提取出的姓名在数据库中没有结果时启用。邮箱接口不接受 forceToGenderize。
代码示例
发送邮箱查询请求
cURL
curl -X POST "https://api.genderapi.io/api/email" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"email":"michael.smith@example.com","country":"US","askToAI":true}'JavaScript
const response = await fetch("https://api.genderapi.io/api/email", {
method: "POST",
headers: { "Content-Type": "application/json", "Authorization": "Bearer YOUR_API_KEY" },
body: JSON.stringify({ email: "michael.smith@example.com", country: "US", askToAI: true })
});
const data = await response.json();Python
import requests
response = requests.post(
"https://api.genderapi.io/api/email",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"email": "michael.smith@example.com", "country": "US", "askToAI": True}
)
print(response.json())200 响应
提取的姓名与性别预测
JSON
{
"status": true,
"used_credits": 1,
"remaining_credits": 4999,
"expires": 1743659200,
"q": "michael.smith@example.com",
"name": "Michael",
"gender": "male",
"country": "US",
"total_names": 10345,
"probability": 97,
"duration": "5ms"
}响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
status | boolean | 请求是否成功完成。 |
used_credits | integer | 本次请求消耗的额度。 |
remaining_credits | integer | 请求完成后的剩余额度。 |
expires | integer | 套餐到期时间,采用 UNIX 时间戳。 |
q | string | 请求中提交的原始邮箱地址。 |
name | string | 从邮箱地址中提取的名字。 |
gender | string | null | 预测值:male、female 或 null。 |
country | string | 预测时采用的国家/地区代码。 |
total_names | integer | 支持该预测的样本数量。 |
probability | integer | 预测置信度百分比。 |
duration | string | 服务器处理时间。 |
请使用完整且有效的邮箱地址
姓名提取取决于邮箱地址结构。通用邮箱、别名或不含可识别姓名的本地部分可能无法返回结果;使用预测前请检查 name、gender 和 probability。
下一篇指南