Get Gender by Name - Single Request

The Get Gender by Name endpoint allows you to determine the gender of a single first name. All parameters are sent via a POST request as JSON. You must authenticate using the Bearer token method in the Authorization header.

Request URL

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

Required HTTP Headers

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

Request Body Parameters

Parameter Type Required Description
name String Yes The first name you want to analyze. Must be a single word without extra titles or prefixes.
country String No A two-letter country code (ISO 3166-1 alpha-2) to improve prediction accuracy. Example: TR for Turkey.
askToAI Boolean No If set to true, the API will ask an AI model to determine the gender if the name cannot be found in the database.
forceToGenderize Boolean No If set to true, the API will attempt to guess a gender even for inputs that are not typical human names, like nicknames or fantasy terms (e.g. sparkling unicorn).

Example Requests


cURL Example

curl -X POST "https://api.genderapi.io/api" \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer YOUR_API_KEY" \
     -d '{"name": "Alice", "country": "US", "askToAI": true, "forceToGenderize": true}'

PHP cURL Example

<?php
$url = "https://api.genderapi.io/api";

$data = array(
    "name" => "Alice",
    "country" => "US",
    "askToAI" => true,
    "forceToGenderize" => 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 Example

fetch("https://api.genderapi.io/api", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_API_KEY"
  },
  body: JSON.stringify({
    name: "Alice",
    country: "US",
    askToAI: true,
    forceToGenderize: true
  })
})
.then(response => response.json())
.then(data => console.log(data));

Python requests Example


import requests

url = "https://api.genderapi.io/api"

payload = {
    "name": "Alice",
    "country": "US",
    "askToAI": True,
    "forceToGenderize": True
}

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_API_KEY"
}

response = requests.post(url, headers=headers, json=payload)

print(response.json())

Example JSON Response

{
  "status": true,
  "used_credits": 1,
  "remaining_credits": 4999,
  "expires": 1743659200,
  "q": "Alice",
  "name": "Alice",
  "gender": "female",
  "country": "US",
  "total_names": 10234,
  "probability": 98,
  "duration": "4ms"
}

Response Fields

Field Type Description
status Boolean Indicates whether the request was successful.
used_credits Integer Number of credits consumed for this request.
remaining_credits Integer Credits left in your account after this request.
expires Integer (timestamp) Package expiration date as a UNIX timestamp.
q String Your input query (the name submitted).
name String The analyzed or extracted first name.
gender Enum[String] Predicted gender. Possible values: male, female, or null.
country String The country code considered during the prediction.
total_names Integer Number of samples used for this prediction.
probability Integer Confidence percentage for the gender prediction.
duration String Time taken to process the request (e.g. 4ms).
Warning: Always ensure that input values like names do not contain unexpected characters. If you plan to use special characters or spaces, ensure proper JSON encoding to avoid errors.