Skip to main content

Official Python SDK for validating and formatting phone numbers using the GenderAPI.io service.

Project description

📞 Phone Number Validation & Formatter API (Python SDK)

The phone-validator library uses the official GenderAPI Phone Number Validation & Formatter API to validate and format phone numbers from over 240 countries.

Whether your users enter phone numbers in various formats (e.g., 12128675309, +1 212 867 5309, 001–212–867–5309), this SDK intelligently detects, validates, and converts them into the standardized E.164 format (e.g., +12128675309).


✅ Features

  • Converts phone numbers to E.164 format
  • Validates if number is real and structurally possible
  • Detects number type: mobile, landline, VoIP, etc.
  • Identifies region/city based on area code
  • Includes country-level metadata (e.g. ISO code, carrier, city)
  • Built with Python, uses the requests package

🔧 Installation

Install via pip:

pip install phone-validator

Or manually from GitHub:

git clone https://github.com/GenderAPI/phone-validator-python.git
cd phone-validator-python
pip install .

🚀 Usage

from phone_validator import PhoneValidator

# Replace with your actual API key
API_KEY = "YOUR_API_KEY"

validator = PhoneValidator(api_key=API_KEY)

result = validator.validate(number="+1 212 867 5309", address="US")

print(result)

🧾 Input Parameters

validate(number, address=None)

Parameter Type Required Description
number string ✅ Yes Phone number in any format
address string Optional ISO country code (US), full country name (Turkey), or city name (Berlin) — helps resolve local numbers

Example:

validator.validate("2128675309", "US")

🌐 API Response

{
  "status": true,
  "remaining_credits": 15709,
  "expires": 0,
  "duration": "18ms",
  "regionCode": "US",
  "countryCode": 1,
  "country": "United States",
  "national": "(212) 867-5309",
  "international": "+1 212-867-5309",
  "e164": "+12128675309",
  "isValid": true,
  "isPossible": true,
  "numberType": "FIXED_LINE_OR_MOBILE",
  "nationalSignificantNumber": "2128675309",
  "rawInput": "+1 212 867 5309",
  "isGeographical": true,
  "areaCode": "212",
  "location": "New York City (Manhattan)"
}

📘 Response Field Reference

Field Description
e164 Number formatted in E.164 standard
isValid, isPossible Validity and structure confirmation
numberType Type of line: mobile, landline, VoIP, etc.
country, regionCode Country name and ISO code
location, areaCode Geo-location details based on number
carrier Carrier (if available)
rawInput, national Original and normalized formats
remaining_credits API credits left in your account

📄 License

This project is licensed under the terms of the MIT license.
See the LICENSE file for details.


🌍 Links

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_phone_validator-1.0.2.tar.gz (4.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_phone_validator-1.0.2-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file genderapi_phone_validator-1.0.2.tar.gz.

File metadata

File hashes

Hashes for genderapi_phone_validator-1.0.2.tar.gz
Algorithm Hash digest
SHA256 ba88c4c34bedc96b3900974e066b54c4165518e889661b9468c638b746e75b86
MD5 6f3d06bc80cdd2ff947cf6eb3d80e2a3
BLAKE2b-256 41f0fa45577ae7d3fb5d8a001e3d8a8022b0fa95e7eb6e8eab9acd541d40b414

See more details on using hashes here.

File details

Details for the file genderapi_phone_validator-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for genderapi_phone_validator-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1e58c0bd5e73d8d5bb620aad964be921797fb73fd8f5a3dd2d9c01a2e33e3177
MD5 500f60d3e582313a1041e2f2774ad5dd
BLAKE2b-256 0a63287580ccc8ae50ad29d2efec9bef8917aac75e648d4c49c77f52b26dda21

See more details on using hashes here.

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