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.


🚀 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

Common Parameters

Parameter Required Description
country No 2-letter country code (e.g. "US")
askToAI No true or false. Default is false. If true, the query goes directly to AI and costs 3 requests. If false, the system tries its internal database first and only uses AI if necessary without spending 3 requests. Recommended for non-latin characters.

Name Lookup

Parameter Required Description
name Yes Name to query

Email Lookup

Parameter Required Description
email Yes Email address to query

Username Lookup

Parameter Required Description
username Yes Username to query

✅ 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"
}

⚖️ 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.0.3.tar.gz (3.8 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.0.3-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for genderapi-1.0.3.tar.gz
Algorithm Hash digest
SHA256 a0fce108ebf0fb2530f34b7d86f845ce38d9f5e6ae2c86c16d11dbfb6ad8701a
MD5 dac5523440c33cb73f48a6adc2039a7b
BLAKE2b-256 3fb10cfb585c317fdcdc13ab794925ab665247573f30fd488886a99d48463c81

See more details on using hashes here.

Provenance

The following attestation bundles were made for genderapi-1.0.3.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.0.3-py3-none-any.whl.

File metadata

  • Download URL: genderapi-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.9 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.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fdbce6ec8f1fabc741ff3e053f2eae6879284c7638d32b33331df76baaf5fe03
MD5 d0b0cf993f80dcea8955749a392ee765
BLAKE2b-256 5dc66215e19c14d6f825a70dc06197e3cfe824206185996df2913f5f5bb9156b

See more details on using hashes here.

Provenance

The following attestation bundles were made for genderapi-1.0.3-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