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
from genderapi import GenderAPI
api = GenderAPI("YOUR_API_KEY")
# Basic usage
result = api.get_gender_by_name(name="Michael")
print(result)
# With askToAI set to True
result = api.get_gender_by_name(name="李雷", askToAI=True)
print(result)
🔹 Get Gender by Email
result = api.get_gender_by_email(email="michael.smith@example.com")
print(result)
# With askToAI set to True
result = api.get_gender_by_email(email="michael.smith@example.com", askToAI=True)
print(result)
🔹 Get Gender by Username
result = api.get_gender_by_username(username="michael_dev")
print(result)
# With askToAI set to True
result = api.get_gender_by_username(username="michael_dev", askToAI=True)
print(result)
📥 API Parameters
Name Lookup
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | String | Yes | Name to query. |
| country | String | No | Two-letter country code (e.g. "US"). Helps narrow down gender detection results by region. |
| askToAI | Boolean | No | Default is false. If true, sends the query directly to AI for maximum accuracy, consuming 3 credits per request. If false, GenderAPI first tries its internal database and uses AI only if necessary, without spending 3 credits. Recommended for non-latin characters or unusual strings. |
| forceToGenderize | Boolean | No | Default is false. When true, analyzes even nicknames, emojis, or unconventional strings like "spider man" instead of returning null for non-standard names. |
Email Lookup
| Parameter | Type | Required | Description |
|---|---|---|---|
| String | Yes | Email address to query. | |
| country | String | No | Two-letter country code (e.g. "US"). Helps narrow down gender detection results by region. |
| askToAI | Boolean | No | Default is false. If true, sends the query directly to AI for maximum accuracy, consuming 3 credits per request. If false, GenderAPI first tries its internal database and uses AI only if necessary, without spending 3 credits. Recommended for non-latin characters or unusual strings. |
Username Lookup
| Parameter | Type | Required | Description |
|---|---|---|---|
| username | String | Yes | Username to query. |
| country | String | No | Two-letter country code (e.g. "US"). Helps narrow down gender detection results by region. |
| askToAI | Boolean | No | Default is false. If true, sends the query directly to AI for maximum accuracy, consuming 3 credits per request. If false, GenderAPI first tries its internal database and uses AI only if necessary, without spending 3 credits. Recommended for non-latin characters or unusual strings. |
| forceToGenderize | Boolean | No | Default is false. When true, analyzes even nicknames, emojis, or unconventional strings like "spider man" instead of returning null for non-standard names. |
✅ API Response
Example JSON response for all endpoints:
{
"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"
}
Response Fields
| Field | Type | Description |
|---|---|---|
| status | Boolean | true or false. Check errors if false. |
| used_credits | Integer | Credits used for this request. |
| remaining_credits | Integer | Remaining credits on your package. |
| expires | Integer (timestamp) | Package expiration date (in seconds). |
| q | String | Your input query (name, email, or username). |
| name | String | Found name. |
| gender | Enum[String] | "male", "female", or "null". |
| country | Enum[String] | Most likely country (e.g. "US", "DE", etc.). |
| total_names | Integer | Number of samples behind the prediction. |
| probability | Integer | Likelihood percentage (50-100). |
| duration | String | Processing time (e.g. "4ms"). |
⚠️ Error Codes
When status is false, check the following error codes:
| errno | errmsg | Description |
|---|---|---|
| 50 | access denied | Unauthorized IP Address or Referrer. Check your access privileges. |
| 90 | invalid country code | Check supported country codes. ISO 3166-1 alpha-2 |
| 91 | name not set || email not set | Missing name or email parameter on your request. |
| 92 | too many names || too many emails | Limit is 100 for names, 50 for emails in one request. |
| 93 | limit reached | The API key credit has been finished. |
| 94 | invalid or missing key | The API key cannot be found. |
| 99 | API key has expired | Please 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:
-
Determine gender from a name:
www.genderapi.io -
Determine gender from an email address:
https://www.genderapi.io/determine-gender-from-email -
Determine gender from a username:
https://www.genderapi.io/determine-gender-from-username
📚 Detailed API Documentation
For the complete API reference, visit:
https://www.genderapi.io/api-documentation
⚖️ License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file genderapi-1.1.1.tar.gz.
File metadata
- Download URL: genderapi-1.1.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1165642ec94df9a52b056396e7976afe75babfa41ee7be7b4011fcac512ff01c
|
|
| MD5 |
315a1fc5ee87593da03fc1819fc6ebe9
|
|
| BLAKE2b-256 |
91bfd21450836d546a190ed0510fc11ead6bc6cf10818f76a34831de0bb275ef
|
Provenance
The following attestation bundles were made for genderapi-1.1.1.tar.gz:
Publisher:
publish-to-pypi.yml on GenderAPI/genderapi-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
genderapi-1.1.1.tar.gz -
Subject digest:
1165642ec94df9a52b056396e7976afe75babfa41ee7be7b4011fcac512ff01c - Sigstore transparency entry: 261415968
- Sigstore integration time:
-
Permalink:
GenderAPI/genderapi-python@3d60f65a2a1b78b6e52c9efe9b3a251a2a668f88 -
Branch / Tag:
refs/tags/v1.1.1 - Owner: https://github.com/GenderAPI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@3d60f65a2a1b78b6e52c9efe9b3a251a2a668f88 -
Trigger Event:
push
-
Statement type:
File details
Details for the file genderapi-1.1.1-py3-none-any.whl.
File metadata
- Download URL: genderapi-1.1.1-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9256187a876a9c497061b9bb6dd5cebc9e491f95e279c1a6e823c298b1f542a1
|
|
| MD5 |
8f6c82dd77848c29b0390fc9f2d1564b
|
|
| BLAKE2b-256 |
ec2508b960bd7d84b0d8c8ec53610edf4037e94738f561dd81c23fbb44560a7f
|
Provenance
The following attestation bundles were made for genderapi-1.1.1-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on GenderAPI/genderapi-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
genderapi-1.1.1-py3-none-any.whl -
Subject digest:
9256187a876a9c497061b9bb6dd5cebc9e491f95e279c1a6e823c298b1f542a1 - Sigstore transparency entry: 261415971
- Sigstore integration time:
-
Permalink:
GenderAPI/genderapi-python@3d60f65a2a1b78b6e52c9efe9b3a251a2a668f88 -
Branch / Tag:
refs/tags/v1.1.1 - Owner: https://github.com/GenderAPI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@3d60f65a2a1b78b6e52c9efe9b3a251a2a668f88 -
Trigger Event:
push
-
Statement type: