이름으로 성별 추정 - 단일 요청
이름으로 성별 추정 엔드포인트는 단일 이름의 성별을 분석할 수 있도록 합니다. 모든 매개변수는 JSON 형식으로 POST 요청을 통해 전송됩니다. 인증은 Authorization 헤더에서 Bearer 토큰 방식을 사용해야 합니다.
요청 URL
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 로 설정하면, 데이터베이스에서 해당 이름을 찾을 수 없는 경우 AI 모델이 성별을 추정합니다.
|
forceToGenderize | Boolean | 아니오 |
true 로 설정하면, 일반적인 이름이 아닌 경우에도 (예: 별명이나 환상적인 용어 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) | 패키지 만료일 (UNIX 타임스탬프 형식)입니다. |
q | String | 입력한 쿼리 (요청한 이름)입니다. |
name | String | 분석되거나 추출된 이름입니다. |
gender | Enum[String] | 예측된 성별입니다. 가능한 값: male , female , null . |
country | String | 예측 시 고려된 국가 코드입니다. |
total_names | Integer | 해당 예측에 사용된 샘플 수입니다. |
probability | Integer | 성별 예측에 대한 신뢰도 백분율입니다. |
duration | String | 요청 처리에 걸린 시간 (예: 4ms ). |
경고:
이름과 같은 입력 값에 예상치 못한 문자가 포함되지 않도록 항상 확인하십시오.
특수 문자나 공백이 포함된 값을 사용할 경우 오류를 방지하기 위해 적절한 JSON 인코딩을 사용해야 합니다.