API security

Authenticate Gender API requests

Use your private API key as a Bearer token or include it in a server-side JSON request body.

HTTPS requiredTwo supported methods

Authentication overview

Choose how to send your API key

All authenticated requests require a valid GenderAPI key. The Authorization header is the recommended default because it separates credentials from your request data.

Recommended

Authorization header

Bearer token

Set Authorization: Bearer YOUR_API_KEY and send only the input parameters in the JSON body.

AuthorizationBearer YOUR_API_KEY
cURL
curl -X POST "https://api.genderapi.io/api" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{"name":"Alice"}'
JavaScript
fetch("https://api.genderapi.io/api", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_API_KEY"
  },
  body: JSON.stringify({ name: "Alice" })
});

Alternative

API key in the JSON body

POST body

Include the key as the key property alongside your request data. Use this method only from trusted server-side code.

cURL
curl -X POST "https://api.genderapi.io/api" \
  -H "Content-Type: application/json" \
  -d '{"name":"Alice","key":"YOUR_API_KEY"}'
Python
import requests

response = requests.post(
  "https://api.genderapi.io/api",
  json={
    "name": "Alice",
    "key": "YOUR_API_KEY"
  }
)
print(response.json())

Credential safety

Protect your API key

  • Store keys in server-side environment variables or a secrets manager.
  • Never commit a key to source control or expose it in browser JavaScript.
  • Remove credentials from application, proxy and analytics logs.
  • Use HTTPS for every request and replace a key if it may have leaked.

Quick comparison

Which method should you use?

MethodBest forCredential location
Bearer tokenRecommendedMost server integrationsAuthorization header
JSON bodyExisting POST integrationskey property
POST content type: Set Content-Type: application/json when sending a JSON request body.

Next guide

Send a single name request

Gender from nameSingle request parameters and response →Client librariesReturn to official SDKs →