Lấy Giới Tính từ Email - Yêu Cầu Nhiều Email
Endpoint Multiple Email cho phép bạn phân tích giới tính của tối đa 50 địa chỉ email trong một lần yêu cầu. Điều này rất hữu ích cho xử lý hàng loạt và tích hợp hiệu suất cao. Tất cả các tham số được gửi qua một yêu cầu POST dưới dạng JSON. Bạn phải xác thực bằng phương thức Bearer token trong header Authorization.
API sẽ trích xuất tên đầu tiên có khả năng cao nhất từ mỗi địa chỉ email và xác định giới tính tương ứng.
Bạn cũng có thể truyền thêm tham số country
tùy chọn và trường id
tuỳ chỉnh
cho từng bản ghi để dễ dàng đối chiếu kết quả với cơ sở dữ liệu của bạn.
URL Yêu Cầu
POST https://api.genderapi.io/api/email/multi/country
HTTP Header Bắt Buộc
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY
Các Tham Số Trong Body Yêu Cầu
Trường | Kiểu Dữ Liệu | Bắt Buộc | Mô Tả |
---|---|---|---|
data | Array of Objects | Có | Mảng các email và các tham số tuỳ chọn. Tối đa 50 phần tử mỗi yêu cầu. |
String | Có (bên trong từng object) | Địa chỉ email cần phân tích. API sẽ trích xuất tên đầu tiên từ đó. | |
country | String | Không |
Mã quốc gia gồm hai ký tự (ISO 3166-1 alpha-2)
để tăng độ chính xác dự đoán. Ví dụ: TR cho Thổ Nhĩ Kỳ.
|
id | String hoặc Integer | Không |
ID tuỳ chọn do bạn tự định nghĩa để đối chiếu kết quả với bản ghi dữ liệu riêng của bạn.
Trường id sẽ được trả về trong phản hồi để phục vụ mục đích đối chiếu.
|
Ví Dụ Request Body
{
"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" }
]
}
Ví Dụ Yêu Cầu
Ví Dụ 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"}]}'
Ví Dụ 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;
?>
Ví Dụ 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));
Ví Dụ 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())
Ví Dụ JSON Phản Hồi
{
"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"
}
Các Trường Trong Phản Hồi
Trường | Kiểu Dữ Liệu | Diễn Giải |
---|---|---|
status | Boolean | Cho biết yêu cầu có thành công hay không. |
used_credits | Integer | Số credit đã sử dụng cho yêu cầu này. |
remaining_credits | Integer | Số credit còn lại trong tài khoản của bạn sau yêu cầu này. |
expires | Integer (timestamp) | Ngày hết hạn gói dịch vụ dưới dạng UNIX timestamp. |
names | Array of objects | Danh sách kết quả cho từng email bạn đã gửi. |
names[].name | String | Tên đầu tiên được trích xuất từ email. |
names[].q | String | Email gốc mà bạn đã gửi. |
names[].gender | Enum[String] | Giới tính dự đoán: male , female , hoặc null . |
names[].country | String | Mã quốc gia được dùng trong quá trình dự đoán. |
names[].total_names | Integer | Số lượng mẫu tên được dùng cho dự đoán. |
names[].probability | Integer | Phần trăm xác suất cho dự đoán giới tính. |
names[].id | String / Integer | Chính id mà bạn gửi trong yêu cầu. Dùng để đối chiếu dữ liệu. |
duration | String | Thời gian xử lý toàn bộ yêu cầu (ví dụ: 5ms ). |