メールアドレスで性別判定 - 複数リクエスト

Multiple Email エンドポイントでは、一度のリクエストで最大 50 件のメールアドレスの性別を解析できます。 これは一括処理や高パフォーマンスな連携に非常に便利です。 全てのパラメータは JSON の POST リクエストで送信します。 認証には Authorization ヘッダーで Bearer トークン方式を使用する必要があります。

API は各メールアドレスから推測される名前を抽出し、それぞれの性別を判定します。 また、各レコードごとにオプションで country フィルタや、 データベース連携用のカスタム id フィールドを渡すことも可能です。

リクエスト URL

POST https://api.genderapi.io/api/email/multi/country

必須 HTTP ヘッダー

  • Content-Type: application/json
  • Authorization: Bearer YOUR_API_KEY

リクエストボディのパラメータ

フィールド 必須 説明
data Object の配列 必須 メールアドレスとオプションパラメータを格納する配列。1 リクエスト最大 50 件。
email String 必須(各オブジェクト内) 解析対象のメールアドレス。API はそこから名前を抽出します。
country String 任意 予測精度を高めるための 2 文字の国コード( 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 Object の配列 各メールアドレスに対する結果リスト。
names[].name String メールアドレスから抽出された名前。
names[].q String 送信した元のメールアドレス。
names[].gender Enum[String] 推定された性別。値は malefemale、または null
names[].country String 予測に使用された国コード。
names[].total_names Integer この予測に使用されたサンプル件数。
names[].probability Integer 性別予測の信頼度(%)。
names[].id String / Integer リクエストで送信した id。自社レコードの照合に利用。
duration String リクエストの処理時間(例:5ms)。