genderize package

Module contents

Client for Genderize.io web service.

class genderize.Genderize(user_agent=None, api_key=None, timeout=30.0)[source]

Bases: object

Client for Genderize.io web service. Uses a Requests session for persistent HTTP connections.

BATCH_SIZE = 10
get(names, country_id=None, language_id=None, retheader=False)[source]

Look up gender for a list of names. Can optionally refine search with locale info. May make multiple requests if there are more names than can be retrieved in one call.

Parameters:
  • names (Iterable[str]) – List of names.
  • country_id (Optional[str]) – Optional ISO 3166-1 alpha-2 country code.
  • language_id (Optional[str]) – Optional ISO 639-1 language code.
  • retheader (Optional[boolean]) – Optional
Returns:

If retheader is False:
List of dicts containing ‘name’, ‘gender’,
‘probability’, ‘count’ keys. If ‘gender’ is None, ‘probability’ and ‘count’ will be omitted.
else:
A dict containing ‘data’ and ‘headers’ keys. Data is the same as when retheader is False. Headers are the response header (a requests.structures.CaseInsensitiveDict). If multiple requests were made, the header will be from the last one.
Return type:Union[dict, Sequence[dict]]
Raises:GenderizeException – if API server returns HTTP error code.
get1(name, **kwargs)[source]

Look up gender for a single name. See get(). Doesn’t support retheader option.

exception genderize.GenderizeException[source]

Bases: exceptions.Exception

Exception from Genderize.io web service.