تحديد الجنس من الاسم - طلب مفرد

تتيح لك نقطة النهاية تحديد الجنس من الاسم معرفة جنس اسم أول واحد. يتم إرسال جميع المعلمات عبر طلب POST بصيغة JSON. يجب عليك التحقق من الهوية باستخدام طريقة Bearer token في ترويسة Authorization.

رابط الطلب

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

ترويسات HTTP المطلوبة

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

معلمات جسم الطلب

المعلمة النوع مطلوب الوصف
name نص (String) نعم الاسم الأول الذي ترغب في تحليله. يجب أن يكون كلمة واحدة فقط بدون ألقاب أو بادئات إضافية.
country نص (String) لا رمز بلد مكون من حرفين (ISO 3166-1 alpha-2) لتحسين دقة التنبؤ. مثال: TR لتركيا.
askToAI قيمة منطقية (Boolean) لا إذا تم تعيينها على true، ستسأل الـ API نموذج ذكاء اصطناعي لتحديد الجنس إذا لم يتم العثور على الاسم في قاعدة البيانات.
forceToGenderize قيمة منطقية (Boolean) لا إذا تم تعيينها على true، ستحاول الـ API تخمين الجنس حتى في حال كانت المدخلات ليست أسماء بشرية نموذجية، مثل الألقاب أو أسماء وهمية (مثال: sparkling unicorn).

أمثلة على الطلبات


مثال cURL

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

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

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


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

مثال على استجابة JSON

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

حقول الاستجابة

الحقل النوع الوصف
status Boolean يشير إلى ما إذا كان الطلب ناجحًا أم لا.
used_credits Integer عدد الاعتمادات المستخدمة لهذا الطلب.
remaining_credits Integer عدد الاعتمادات المتبقية في حسابك بعد هذا الطلب.
expires Integer (timestamp) تاريخ انتهاء الحزمة بتنسيق طابع يونكس الزمني.
q String استعلام الإدخال الخاص بك (الاسم المرسل).
name String الاسم الذي تم تحليله أو استخراجه.
gender Enum[String] الجنس المتوقع. القيم الممكنة: male أو female أو null.
country String رمز البلد المستخدم أثناء التنبؤ.
total_names Integer عدد العينات المستخدمة لهذا التنبؤ.
probability Integer نسبة الثقة في التنبؤ بالجنس.
duration String المدة الزمنية لمعالجة الطلب (مثلاً 4ms).
تحذير: تأكد دائمًا من أن القيم المدخلة مثل الأسماء لا تحتوي على أحرف غير متوقعة. إذا كنت تخطط لاستخدام أحرف خاصة أو مسافات، تأكد من ترميز JSON بشكل صحيح لتجنب الأخطاء.