Ottieni il genere tramite email – Richiesta singola
L’endpoint Get Gender by Email ti consente di determinare il genere di una persona analizzando il suo indirizzo email.
Tutti i parametri vengono inviati tramite una richiesta POST in formato JSON.
Devi autenticarti utilizzando il metodo Bearer token nell’header Authorization.
URL della richiesta
POST https://api.genderapi.io/api/email
Header HTTP richiesti
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY
Parametri del body della richiesta
Parametro |
Tipo |
Obbligatorio |
Descrizione |
email |
String |
Sì |
L’indirizzo email da analizzare. L’API estrarrà il nome proprio prima di determinare il genere.
|
country |
String |
No |
Un codice paese di due lettere (ISO 3166-1 alpha-2) per migliorare la precisione della previsione.
Esempio: TR per la Turchia.
|
askToAI |
Boolean |
No |
Se impostato su true , l’API chiederà a un modello di intelligenza artificiale di determinare il genere se il nome estratto non si trova nel database.
|
Esempi di richiesta
Esempio 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}'
Esempio 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;
?>
Esempio 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));
Esempio 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())
Esempio di risposta 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"
}
Campi della risposta
Campo |
Tipo |
Descrizione |
status |
Boolean |
Indica se la richiesta è andata a buon fine. |
used_credits |
Integer |
Numero di crediti utilizzati per questa richiesta. |
remaining_credits |
Integer |
Crediti rimasti sul tuo account dopo questa richiesta. |
expires |
Integer (timestamp) |
Data di scadenza del pacchetto come UNIX timestamp. |
q |
String |
La tua query inviata (l’email). |
name |
String |
Il nome estratto dall’indirizzo email. |
gender |
Enum[String] |
Genere previsto. Valori possibili: male , female o null . |
country |
String |
Codice paese utilizzato per la previsione. |
total_names |
Integer |
Numero di campioni usati per questa previsione. |
probability |
Integer |
Percentuale di affidabilità della previsione di genere. |
duration |
String |
Tempo impiegato per elaborare la richiesta (ad es. 5ms ). |