รับข้อมูลเพศจากอีเมล - คำขอเดี่ยว

จุดเชื่อมต่อ Get Gender by Email ช่วยให้คุณสามารถระบุเพศของบุคคลได้ โดยการวิเคราะห์ที่อยู่อีเมลของพวกเขา พารามิเตอร์ทั้งหมดจะถูกส่งผ่านคำขอแบบ POST ในรูปแบบ JSON
คุณต้องยืนยันตัวตนด้วยวิธี Bearer token ในส่วนหัว Authorization

URL สำหรับคำขอ

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

HTTP Headers ที่จำเป็น

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

พารามิเตอร์ของเนื้อหาคำขอ (Request Body)

พารามิเตอร์ ประเภท จำเป็น คำอธิบาย
email String ใช่ ที่อยู่อีเมลที่ต้องการวิเคราะห์ API จะดึงชื่อแรกที่เป็นไปได้จากอีเมลนั้นเพื่อใช้ในการระบุเพศ
country String ไม่ รหัสประเทศ 2 ตัวอักษร (ISO 3166-1 alpha-2) เพื่อช่วยเพิ่มความแม่นยำในการคาดการณ์ เช่น TH สำหรับประเทศไทย
askToAI Boolean ไม่ หากตั้งค่าเป็น true ระบบจะให้โมเดล AI วิเคราะห์เพศในกรณีที่ไม่พบชื่อที่แยกออกมาในฐานข้อมูล

คำขอตัวอย่าง


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}'

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

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

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

ตัวอย่างการตอบกลับในรูปแบบ 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"
}

คำอธิบายฟิลด์การตอบกลับ

ฟิลด์ ประเภท คำอธิบาย
status Boolean ระบุว่าคำขอสำเร็จหรือไม่
used_credits Integer จำนวนเครดิตที่ใช้ในการเรียกครั้งนี้
remaining_credits Integer เครดิตที่เหลืออยู่ในบัญชีของคุณหลังจากคำขอนี้
expires Integer (timestamp) วันที่หมดอายุของแพ็กเกจในรูปแบบ UNIX timestamp
q String ข้อมูลอีเมลที่คุณส่งมา
name String ชื่อแรกที่ถูกแยกออกมาจากอีเมล
gender Enum[String] เพศที่คาดการณ์ได้: male, female หรือ null
country String รหัสประเทศที่ใช้ในการประเมินเพศ
total_names Integer จำนวนตัวอย่างชื่อที่ใช้สำหรับการคาดการณ์นี้
probability Integer เปอร์เซ็นต์ความมั่นใจของผลลัพธ์เพศที่คาดการณ์ได้
duration String ระยะเวลาในการประมวลผลคำขอ (เช่น 5ms)