Get Gender by Username - Single Request
The Get Gender by Username endpoint allows you to determine the gender of a person
by analyzing a username or nickname. 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/username
Required HTTP Headers
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY
Request Body Parameters
Parameter |
Type |
Required |
Description |
username |
String |
Yes |
The username or nickname to analyze. This can be a social media handle, screen name, or alias.
May contain non-name words like fantasy terms or brand references.
|
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 extracted name
cannot be found in the database.
|
forceToGenderize |
Boolean |
No |
If set to true , the API will attempt to guess a gender even for usernames that do not look like
real human names, such as fantasy terms or nicknames (e.g. sparkling_unicorn ).
|
Example Requests
cURL Example
curl -X POST "https://api.genderapi.io/api/username" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"username": "sparkling_unicorn", "country": "US", "askToAI": true, "forceToGenderize": true}'
PHP cURL Example
<?php
$url = "https://api.genderapi.io/api/username";
$data = array(
"username" => "sparkling_unicorn",
"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/username", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
},
body: JSON.stringify({
username: "sparkling_unicorn",
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/username"
payload = {
"username": "sparkling_unicorn",
"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": "sparkling_unicorn",
"name": "Sparkling",
"gender": "female",
"country": "US",
"total_names": 9876,
"probability": 92,
"duration": "6ms"
}
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 username submitted). |
name |
String |
The extracted first name from the username. |
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. 6ms ). |