通过邮箱批量获取性别
Multiple Email 端点允许你在一次请求中分析最多 50 个邮箱地址的性别,非常适合批量处理和高性能集成。 所有参数需通过 POST 请求并以 JSON 格式提交。你必须在 Authorization 头中使用 Bearer token 方法进行认证。
API 会从每个邮箱中提取可能的名字,并为每个邮箱判断性别。
你还可以为每条记录传递可选的 country
(国家代码)和自定义 id
字段,用于和你的数据库结果进行匹配。
请求 URL
POST https://api.genderapi.io/api/email/multi/country
所需 HTTP 头部
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY
请求体参数
字段 | 类型 | 是否必填 | 说明 |
---|---|---|---|
data | 对象数组 | 是 | 邮箱和其可选参数的数组。每次请求最多 50 条。 |
String | 是(每个对象内) | 要分析的邮箱地址,API 会自动提取可能的名字。 | |
country | String | 否 |
两位国家代码(ISO 3166-1 alpha-2)提升准确率。例如:土耳其为 TR 。
|
id | String 或 Integer | 否 |
可选 ID,用于和你的数据库关联。此 id 会原样返回到结果中,方便你做数据匹配。
|
请求体示例
{
"data": [
{ "email": "andrea.schmidt@example.com", "country": "DE", "id": "123" },
{ "email": "andrea.rossi@example.it", "country": "IT", "id": "456" },
{ "email": "james.brown@example.com", "country": "US", "id": "789" }
]
}
请求示例
cURL 示例
curl -X POST "https://api.genderapi.io/api/email/multi/country" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"data":[{"email":"andrea.schmidt@example.com","country":"DE","id":"123"},{"email":"andrea.rossi@example.it","country":"IT","id":"456"},{"email":"james.brown@example.com","country":"US","id":"789"}]}'
PHP cURL 示例
<?php
$url = "https://api.genderapi.io/api/email/multi/country";
$data = array(
"data" => array(
array(
"email" => "andrea.schmidt@example.com",
"country" => "DE",
"id" => "123"
),
array(
"email" => "andrea.rossi@example.it",
"country" => "IT",
"id" => "456"
),
array(
"email" => "james.brown@example.com",
"country" => "US",
"id" => "789"
)
)
);
$payload = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Authorization": "Bearer YOUR_API_KEY"
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
JavaScript fetch 示例
fetch("https://api.genderapi.io/api/email/multi/country", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
},
body: JSON.stringify({
data: [
{ email: "andrea.schmidt@example.com", country: "DE", id: "123" },
{ email: "andrea.rossi@example.it", country: "IT", id: "456" },
{ email: "james.brown@example.com", country: "US", id: "789" }
]
})
})
.then(response => response.json())
.then(data => console.log(data));
Python requests 示例
import requests
url = "https://api.genderapi.io/api/email/multi/country"
payload = {
"data": [
{ "email": "andrea.schmidt@example.com", "country": "DE", "id": "123" },
{ "email": "andrea.rossi@example.it", "country": "IT", "id": "456" },
{ "email": "james.brown@example.com", "country": "US", "id": "789" }
]
}
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
JSON 返回示例
{
"status": true,
"used_credits": 3,
"remaining_credits": 7265,
"expires": 1717069765,
"names": [
{
"name": "Andrea",
"q": "andrea.schmidt@example.com",
"gender": "female",
"country": "DE",
"total_names": 644,
"probability": 88,
"id": "123"
},
{
"name": "Andrea",
"q": "andrea.rossi@example.it",
"gender": "male",
"country": "IT",
"total_names": 13537,
"probability": 98,
"id": "456"
},
{
"name": "James",
"q": "james.brown@example.com",
"gender": "male",
"country": "US",
"total_names": 45274,
"probability": 100,
"id": "789"
}
],
"duration": "5ms"
}
返回字段说明
字段 | 类型 | 说明 |
---|---|---|
status | Boolean | 请求是否成功。 |
used_credits | Integer | 本次请求消耗的积分数量。 |
remaining_credits | Integer | 本次请求后你账户剩余的积分。 |
expires | Integer (timestamp) | 套餐到期时间(UNIX 时间戳)。 |
names | 对象数组 | 每个输入邮箱的结果列表。 |
names[].name | String | 从邮箱中提取到的名字。 |
names[].q | String | 你请求时提交的原始邮箱。 |
names[].gender | Enum[String] | 预测性别,可能为 male 、female 或 null 。 |
names[].country | String | 性别推断时考虑的国家代码。 |
names[].total_names | Integer | 用于预测的样本数量。 |
names[].probability | Integer | 预测可信度百分比。 |
names[].id | String / Integer | 你在请求中发送的 id ,用于与你的数据库数据匹配。 |
duration | String | 本次请求的总处理时长(如 5ms )。 |