Skip to main content

Official Python SDK for GenderAPI.io

Project description

genderapi-python

Official Python SDK for GenderAPI.io — determine gender from names, emails, and usernames using AI.


Get Free API Key: https://app.genderapi.io


🚀 Installation

Install the required package:

pip install genderapi

📝 Usage


🔹 Get Gender by Name (Single)

from genderapi import GenderAPI

api = GenderAPI("YOUR_API_KEY")

# Basic usage
result = api.get_gender_by_name(name="Michael")
print(result)

# With askToAI and forceToGenderize
result = api.get_gender_by_name(name="李雷", country="CN", askToAI=True, forceToGenderize=True)
print(result)

🔹 Get Gender by Email (Single)

result = api.get_gender_by_email(email="michael.smith@example.com")
print(result)

# With country and askToAI
result = api.get_gender_by_email(email="michael.smith@example.com", country="US", askToAI=True)
print(result)

🔹 Get Gender by Username (Single)

result = api.get_gender_by_username(username="michael_dev")
print(result)

# With country, askToAI and forceToGenderize
result = api.get_gender_by_username(username="spider_man", country="US", askToAI=True, forceToGenderize=True)
print(result)

🔹 Get Gender by Multiple Names (Bulk)

Analyze up to 100 names in a single request.

result = api.get_gender_by_name_bulk([
    {"name": "Andrea", "country": "DE", "id": "123"},
    {"name": "andrea", "country": "IT", "id": "456"},
    {"name": "james", "country": "US", "id": "789"}
])

print(result)

🔹 Get Gender by Multiple Emails (Bulk)

Analyze up to 50 emails in a single request.

result = api.get_gender_by_email_bulk([
    {"email": "john@example.com", "country": "US", "id": "abc123"},
    {"email": "maria@domain.de", "country": "DE", "id": "def456"}
])

print(result)

🔹 Get Gender by Multiple Usernames (Bulk)

Analyze up to 50 usernames in a single request.

result = api.get_gender_by_username_bulk([
    {"username": "johnblack", "country": "US", "id": "u001"},
    {"username": "maria2025", "country": "DE", "id": "u002"}
])

print(result)

📥 API Parameters


Name Lookup (Single)

Parameter Type Required Description
name String Yes Name to query.
country String No Two-letter country code (e.g. "US"). Helps improve accuracy.
askToAI Boolean No Default is False. If True, sends query directly to AI for max accuracy, consuming 3 credits.
forceToGenderize Boolean No Default is False. When True, analyzes nicknames, emojis, or unconventional strings instead of returning null.

Name Lookup (Bulk)

Parameter Type Required Description
data List Yes List of name objects (max 100 per request).
name String Yes Name to analyze (inside each object).
country String No Two-letter country code.
id String/Integer No Optional. Your own ID to match responses to records.

Email Lookup (Single)

Parameter Type Required Description
email String Yes Email address to analyze.
country String No Two-letter country code.
askToAI Boolean No Default is False. If True, forces AI lookup.

Email Lookup (Bulk)

Parameter Type Required Description
data List Yes List of email objects (max 50 per request).
email String Yes Email to analyze (inside each object).
country String No Two-letter country code.
id String/Integer No Optional. Your own ID to match responses to records.

Username Lookup (Single)

Parameter Type Required Description
username String Yes Username to analyze.
country String No Two-letter country code.
askToAI Boolean No Default is False. Forces AI lookup if True.
forceToGenderize Boolean No Default is False. Analyzes unconventional strings if True.

Username Lookup (Bulk)

Parameter Type Required Description
data List Yes List of username objects (max 50 per request).
username String Yes Username to analyze (inside each object).
country String No Two-letter country code.
id String/Integer No Optional. Your own ID to match responses to records.

✅ API Response


Single Response

Example JSON response for single name, email, or username lookups:

{
  "status": true,
  "used_credits": 1,
  "remaining_credits": 4999,
  "expires": 1743659200,
  "q": "michael.smith@example.com",
  "name": "Michael",
  "gender": "male",
  "country": "US",
  "total_names": 325,
  "probability": 98,
  "duration": "4ms"
}

Bulk (Multiple) Response

Example JSON response for bulk name lookup (same structure for email and username bulk lookups):

{
  "status": true,
  "used_credits": 3,
  "remaining_credits": 7265,
  "expires": 1717069765,
  "names": [
    {
      "name": "andrea",
      "q": "Andrea",
      "gender": "female",
      "country": "DE",
      "total_names": 644,
      "probability": 88,
      "id": "123"
    },
    {
      "name": "andrea",
      "q": "andrea",
      "gender": "male",
      "country": "IT",
      "total_names": 13537,
      "probability": 98,
      "id": "456"
    },
    {
      "name": "james",
      "q": "james",
      "gender": "male",
      "country": "US",
      "total_names": 45274,
      "probability": 100,
      "id": "789"
    }
  ],
  "duration": "5ms"
}

Response Fields

Field Type Description
status Boolean Indicates whether the request was successful.
used_credits Integer Number of credits consumed for this request.
remaining_credits Integer Remaining credits on your package.
expires Integer (timestamp) Expiration date of your package (UNIX timestamp).
q String Original query input (only in single response).
name String Normalized name/email/username.
gender Enum[String] "male", "female", or "null".
country String Country used in prediction.
total_names Integer Number of samples used for prediction.
probability Integer Confidence percentage for the prediction.
names Array of Objects List of results (only in bulk response).
id String / Integer Your own ID returned back (bulk only).
duration String Processing time for the request.

⚠️ Limits

  • Single requests → 1 item per call.
  • Bulk Name Lookup → max 100 names per request.
  • Bulk Email Lookup → max 50 emails per request.
  • Bulk Username Lookup → max 50 usernames per request.

⚠️ Error Codes

When status is false, check the following error codes:

errno errmsg Description
50 access denied Unauthorized IP or referrer.
90 invalid country code Country code is invalid.
91 name/email/username not set Missing required parameter.
92 too many items in bulk Limit exceeded (100 for names, 50 for emails/usernames).
93 limit reached Credits depleted.
94 invalid or missing key API key is invalid or missing.
99 API key has expired Renew your API key.

Example error response:

{
  "status": false,
  "errno": 94,
  "errmsg": "invalid or missing key"
}

🔗 Live Test Pages

You can try live gender detection directly on GenderAPI.io:


📚 Detailed API Documentation

For the complete API reference, visit:

https://www.genderapi.io/api-documentation


⚖️ License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

genderapi-1.1.4.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

genderapi-1.1.4-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file genderapi-1.1.4.tar.gz.

File metadata

  • Download URL: genderapi-1.1.4.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for genderapi-1.1.4.tar.gz
Algorithm Hash digest
SHA256 29d35acffa3df68146713ccaa9e5ff9a78a3f4db9fc5515a7f507d0bb5361630
MD5 b6fe4bd7b258ba5cb38261f63351589c
BLAKE2b-256 8aa2c06302382ba447fa75c87596b52dbc5349b1bcc741bf8e78ae75764ac5b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for genderapi-1.1.4.tar.gz:

Publisher: publish-to-pypi.yml on GenderAPI/genderapi-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file genderapi-1.1.4-py3-none-any.whl.

File metadata

  • Download URL: genderapi-1.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for genderapi-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fe2636214cacf0ecddbd389a98e73dc43481a43fb557ef53a31cbf048e09fa8a
MD5 6dcef456bf882959b48207987831aa2d
BLAKE2b-256 61e16c8f1b0cd13dce054cbfc5b2732bbbe08e0bf70c29aa4cd82cec6aacb471

See more details on using hashes here.

Provenance

The following attestation bundles were made for genderapi-1.1.4-py3-none-any.whl:

Publisher: publish-to-pypi.yml on GenderAPI/genderapi-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page