メールアドレスで性別判定 - 単一リクエスト
Get Gender by Email エンドポイントは、メールアドレスを解析して
性別を判定する機能を提供します。すべてのパラメータは JSON の POST リクエストで送信されます。
認証には Authorization ヘッダーで Bearer トークン方式を使用する必要があります。
リクエスト URL
POST https://api.genderapi.io/api/email
必須 HTTP ヘッダー
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY
リクエストボディのパラメータ
パラメータ |
型 |
必須 |
説明 |
email |
String |
必須 |
解析対象のメールアドレス。API はこのメールアドレスから
推定される名前を抽出した後、性別を判定します。
|
country |
String |
任意 |
性別判定の精度を高めるための 2 文字の国コード(
ISO 3166-1 alpha-2)。
例:TR はトルコ。
|
askToAI |
Boolean |
任意 |
true を設定すると、
抽出した名前がデータベースに存在しない場合に
AI モデルを利用して性別を判定します。
|
リクエスト例
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}'
PHP cURL の例
<?php
$url = "https://api.genderapi.io/api/email";
$data = array(
"email" => "michael.smith@example.com",
"country" => "US",
"askToAI" => true
);
$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", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
},
body: JSON.stringify({
email: "michael.smith@example.com",
country: "US",
askToAI: true
})
})
.then(response => response.json())
.then(data => console.log(data));
Python requests の例
import requests
url = "https://api.genderapi.io/api/email"
payload = {
"email": "michael.smith@example.com",
"country": "US",
"askToAI": True
}
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": 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 (timestamp) |
パッケージの有効期限(UNIX タイムスタンプ)。 |
q |
String |
送信した元のメールアドレス。 |
name |
String |
メールアドレスから抽出された名前。 |
gender |
Enum[String] |
推定された性別。値は male 、female 、または null 。 |
country |
String |
予測に使用された国コード。 |
total_names |
Integer |
この予測に使用されたサンプル数。 |
probability |
Integer |
性別予測の信頼度(%)。 |
duration |
String |
リクエストの処理時間(例:5ms )。 |