Batch names, emails and usernames
POST /gender/batch accepts an items array with 1–50 items for API-key access, or at most 10 for the IP trial. You can send only names, only emails, only usernames, or mix all three. Each item has its own country, forceToGenderize and options. IDs are optional and must be unique.
Results preserve input order and include index, your optional id, charged_credits and exactly one of data or error. HTTP 200 can contain item-level failures, so inspect every item. meta.summary reports total, succeeded, identified, unknown and failed. An unknown prediction is a successful, billable item.
Request validation or planning failure rejects the batch before debit. If every executed item fails, the API returns a non-2xx Problem response with a data array and a legacy results alias. Failed items cost zero after a confirmed refund. If billing is unconfirmed, do not assume item charges are final.
Choose your language. Set up your API key, then run the example on your server.
Every prediction request is a new billable operation, including retries. These examples do not automatically retry. Check billing status before sending another request.
Before you run: access and error handling
Run these examples on your server. Set GENDERAPI_API_KEY in the process environment to your existing API key. Confirm meta.access.mode is api_key: an unrecognized key can fall back to the IP trial.
HTTP 4xx and 5xx JSON responses preserve the error body and return a nonzero exit status. Check code, action and meta.usage.billing_status before retrying. For HTTP 200 batch responses, also inspect each item's data or error.
Error and retry guide →cURL 7.76+ in a POSIX shell. Run in your terminal. Runtime documentation
Node.js 22+; built-in fetch. Save as example.mjs and run node example.mjs. Runtime documentation
Python 3.10+; standard library. Save as example.py and run python3 example.py. Runtime documentation
PHP 8+ with the cURL extension. Save as example.php and run php example.php. Runtime documentation
Java 17+; standard HTTP client. Save as GenderApiExample.java and run java GenderApiExample.java. Runtime documentation
.NET 8+ console application. Use as Program.cs in a console project, then run dotnet run. Runtime documentation
Go 1.22+; standard library. Save as main.go and run go run main.go. Runtime documentation
Read a batch response
This independent synthetic example contains a dataset match, an unknown result and a provider failure. It illustrates a partial-success HTTP 200 response, not the expected output of the batch request above. The two successful items cost 1 credit each; the failed item has a confirmed zero charge.
{
"data": [
{
"index": 0,
"id": "known",
"charged_credits": 1,
"data": {
"input": {
"type": "name",
"value": "Onur",
"country": "TR"
},
"name": "onur",
"gender": "male",
"country": "TR",
"confidence": 0.9,
"confidence_kind": "observed_frequency",
"sample_count": 100,
"source": "dataset",
"result_status": "identified",
"reason": null,
"country_source": "dataset",
"match": {
"name": "onur",
"method": "normalized",
"scope": "country",
"country": "TR"
}
}
},
{
"index": 1,
"id": "missing",
"charged_credits": 1,
"data": {
"input": {
"type": "name",
"value": "zzzxxyy",
"country": null
},
"name": null,
"gender": null,
"country": null,
"confidence": null,
"confidence_kind": null,
"sample_count": null,
"source": "none",
"result_status": "unknown",
"reason": "not_found",
"country_source": null,
"match": {
"name": null,
"method": null,
"scope": null,
"country": null
}
}
},
{
"index": 2,
"id": "failed",
"charged_credits": 0,
"error": {
"type": "urn:genderapi:problem:ai_upstream_error",
"title": "ai upstream error",
"status": 502,
"detail": "The AI provider could not complete the request.",
"instance": "urn:uuid:11111111-1111-4111-8111-111111111111",
"code": "ai_upstream_error",
"request_id": "11111111-1111-4111-8111-111111111111",
"documentation": "https://api.genderapi.io/api/v2/errors",
"action": "inspect_billing_before_retry"
}
}
],
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111",
"duration_ms": 12,
"access": {
"mode": "ip_trial",
"reason": "api_key_missing"
},
"usage": {
"charged_credits": 2,
"remaining_credits": 6,
"billing_status": "confirmed",
"resets_at": "2026-09-26T12:00:00.000Z",
"limit": 10,
"period_seconds": 86400
},
"summary": {
"total": 3,
"succeeded": 2,
"identified": 1,
"unknown": 1,
"failed": 1
}
}
}Plan batch credits and retries
Authenticate with your existing Bearer API key and send Content-Type: application/json. Every submitted batch is a new operation. If retrying a partial failure, submit only the failed items after checking billing; resending successful items charges them again.
Batch items default to AI off and cost 1 credit per successful item. Explicit fallback also costs 1 total, including AI. Always costs 2. forceToGenderize costs 1 for a resolved dataset result or 2 if AI is used. Successful unknowns are charged. One positive starting credit is enough to begin the batch; its final charge may leave a negative balance.