Request overview
हर request में एक name भेजें
First name के साथ JSON object submit करें और Bearer token से authenticate करें। Regional naming patterns prediction सुधार सकते हों तो country code जोड़ें।
जरूरी HTTP headers
Request authorize करें
Content-Typeapplication/jsonAuthorizationBearer YOUR_API_KEYJSON request body
Parameters
| Parameter | Type | Requirement | Description |
|---|---|---|---|
name | string | जरूरी | Analyze करने के लिए first name। Titles या prefixes के बिना clean name value भेजें। |
country | string | वैकल्पिक | Regional context के लिए IN या US जैसा ISO 3166-1 alpha-2 country code। |
askToAI | boolean | वैकल्पिक | true होने पर database में name न मिलने पर AI fallback इस्तेमाल करें। |
forceToGenderize | boolean | वैकल्पिक | true होने पर nicknames या typical name जैसे न दिखने वाले inputs के लिए result try करें। |
askToAI केवल database में result न मिलने पर लागू होता है। Unusual inputs पर forced predictions कम reliable हो सकते हैं, इसलिए probability को महत्वपूर्ण signal मानें।
Code examples
Single request भेजें
ये examples Bearer authentication से वही request भेजते हैं।
curl -X POST "https://api.genderapi.io/api" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"name":"Priya","country":"IN","askToAI":true}'const response = await fetch("https://api.genderapi.io/api", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
},
body: JSON.stringify({ name: "Priya", country: "IN", askToAI: true })
});
const data = await response.json();import requests
response = requests.post(
"https://api.genderapi.io/api",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"name": "Priya", "country": "IN", "askToAI": True}
)
print(response.json())200 response
Prediction result
{
"status": true,
"used_credits": 1,
"remaining_credits": 4999,
"expires": 1743659200,
"q": "Priya",
"name": "Priya",
"gender": "female",
"country": "IN",
"total_names": 10234,
"probability": 98,
"duration": "4ms"
}Response fields की जानकारी
| Field | Type | Description |
|---|---|---|
status | boolean | Request सफलतापूर्वक पूरा हुआ या नहीं। |
used_credits | integer | इस request में इस्तेमाल हुए credits। |
remaining_credits | integer | Request के बाद उपलब्ध credits। |
expires | integer | Package expiry का UNIX timestamp। |
q | string | Request में भेजा गया original name। |
name | string | GenderAPI द्वारा analyze किया गया name। |
gender | string | null | Predicted value: male, female या null। |
country | string | Prediction में इस्तेमाल हुआ country code। |
total_names | integer | Prediction को support करने वाले samples की संख्या। |
probability | integer | प्रतिशत में prediction probability। |
duration | string | Server processing time। |
Clean और correctly encoded input भेजें
Titles या prefixes के बिना first name इस्तेमाल करें। JSON clients encoding automatically संभालते हैं, लेकिन request body बनाने से पहले external input हमेशा validate करें।
अगली गाइड