Geslacht opvragen via e-mail – enkele aanvraag

Het Get Gender by Email-eindpunt maakt het mogelijk om het geslacht van een persoon te bepalen door zijn of haar e-mailadres te analyseren. Alle parameters worden via een POST-verzoek als JSON verzonden. Je moet authenticeren met de Bearer-token methode in de Authorization-header.

Request-URL

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

Vereiste HTTP-headers

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

Body-parameters van het verzoek

Parameter Type Vereist Beschrijving
email String Ja Het e-mailadres dat geanalyseerd moet worden. De API haalt eerst de waarschijnlijke voornaam uit het e-mailadres voordat het geslacht wordt bepaald.
country String Nee Een landcode van twee letters (ISO 3166-1 alpha-2) om de nauwkeurigheid van de voorspelling te verbeteren. Bijvoorbeeld: TR voor Turkije.
askToAI Boolean Nee Als deze op true staat, zal de API een AI-model raadplegen om het geslacht te bepalen als de uit het e-mailadres gehaalde naam niet in de database gevonden wordt.

Voorbeeldverzoeken


cURL-voorbeeld

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-voorbeeld

<?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-voorbeeld

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-voorbeeld

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())

Voorbeeld van JSON-respons

{
  "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"
}

Responsvelden

Veld Type Beschrijving
status Boolean Geeft aan of het verzoek is geslaagd.
used_credits Integer Aantal gebruikte credits voor dit verzoek.
remaining_credits Integer Resterende credits op je account na dit verzoek.
expires Integer (timestamp) Vervaldatum van het pakket als UNIX timestamp.
q String Je ingevoerde query (het verzonden e-mailadres).
name String De uit het e-mailadres gehaalde voornaam.
gender Enum[String] Voorspeld geslacht. Mogelijke waarden: male, female of null.
country String Landcode gebruikt bij de voorspelling.
total_names Integer Aantal samples gebruikt voor deze voorspelling.
probability Integer Betrouwbaarheidspercentage van de voorspelling.
duration String Tijd nodig om het verzoek te verwerken (bijv. 5ms).