사용자 이름으로 성별 확인 - 단일 요청

사용자 이름으로 성별 확인 엔드포인트를 사용하면 사용자 이름이나 닉네임을 분석하여 해당 인물의 성별을 판별할 수 있습니다. 모든 파라미터는 JSON 형식의 POST 요청으로 전송됩니다. 인증은 Authorization 헤더에서 Bearer 토큰 방식을 사용해야 합니다.

요청 URL

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

필수 HTTP 헤더

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

요청 본문 파라미터

파라미터 타입 필수 여부 설명
username 문자열 분석할 사용자 이름 또는 닉네임입니다. 소셜 미디어 핸들, 스크린 네임, 또는 별명일 수 있습니다. 판타지 용어나 브랜드 이름 같은 실제 이름이 아닌 단어들을 포함할 수도 있습니다.
country 문자열 아니오 성별 예측 정확도를 높이기 위한 두 글자의 국가 코드 (ISO 3166-1 alpha-2). 예: 터키의 경우 TR.
askToAI 불리언 아니오 true로 설정하면, 추출된 이름이 데이터베이스에 없을 경우 AI 모델이 성별을 예측하도록 요청합니다.
forceToGenderize 불리언 아니오 true로 설정하면, API는 sparkling_unicorn처럼 실제 인명처럼 보이지 않는 사용자 이름에 대해서도 성별을 추측하려 시도합니다.

요청 예시


cURL 예시

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 예시

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

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 예시

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

JSON 응답 예시

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

응답 필드

필드 타입 설명
status Boolean 요청이 성공했는지 여부를 나타냅니다.
used_credits Integer 이번 요청에 사용된 크레딧 수입니다.
remaining_credits Integer 요청 후 계정에 남은 크레딧 수입니다.
expires Integer (타임스탬프) 패키지 만료 날짜 (UNIX 타임스탬프 형식).
q String 입력한 사용자 이름 (요청 시 전달된 값).
name String 사용자 이름에서 추출된 이름입니다.
gender Enum[String] 예측된 성별. 가능한 값: male, female, 또는 null.
country String 예측 시 고려된 국가 코드입니다.
total_names Integer 예측에 사용된 이름 샘플 수입니다.
probability Integer 성별 예측의 신뢰도 비율(%)입니다.
duration String 요청 처리에 걸린 시간 (예: 6ms).