genderapi_batch: Infer gender for a batch of 1 to 50 items

View source: R/gender.R

genderapi_batchR Documentation

Infer gender for a batch of 1 to 50 items

Description

Sends one POST /gender/batch request with ⁠{"items": [...]}⁠. Batch items default to ai_mode = "off" on the server. The server decides the limit (50 items; 10 on the IP trial). Larger jobs must be split by the caller; the package never retries or splits automatically.

Usage

genderapi_batch(items, client = genderapi_client())

Arguments

items

The items: a list of genderapi_item() objects, a list of plain lists using either the argument names of genderapi_item() or the wire names (type, value, country, id, forceToGenderize, options = list(ai_mode = ...)), or a data frame with columns type, value and optionally country, ai_mode, force_to_genderize, id (NA means "not set").

client

A genderapi_client().

Details

A partially successful batch is returned normally (HTTP 200): inspect every item. Each item has index, the optional id, charged_credits and exactly one of data (a prediction) or error (a problem with code). meta$summary has total, succeeded, identified, unknown and failed. When every executed item fails the API answers with an error status; the resulting genderapi_http_error keeps the item array in data.

Retry only failed items, and only once billing is confirmed: resubmitting successful items charges them again.

Value

A genderapi_batch: the parsed V2 JSON with data (the item list) and meta (including summary and usage). Use as.data.frame() for one row per item and genderapi_failed() for the failed items.

Examples

items <- list(
  genderapi_item("name", "Onur", country = "TR", id = "a"),
  genderapi_item("email", "alex@example.com", id = "b")
)
## Not run: 
# Sends a request and may consume credits.
res <- genderapi_batch(items)
res$meta$summary
as.data.frame(res)
genderapi_failed(res)

## End(Not run)

genderapi documentation built on Oct. 1, 2026, 5:13 p.m.