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
requestspackage
🔧 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
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_phone_validator-1.0.1.tar.gz.
File metadata
- Download URL: genderapi_phone_validator-1.0.1.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c7004b7809fcd4b5deac4d7598e84502d43cf19499febf44715f39e1643cb5e
|
|
| MD5 |
c1fc33690d07e4d35031411abb4805b9
|
|
| BLAKE2b-256 |
698d57cbd3a6c81620e127350a92d37e3485631e5ba3b7521360e9a6eb64957d
|
File details
Details for the file genderapi_phone_validator-1.0.1-py3-none-any.whl.
File metadata
- Download URL: genderapi_phone_validator-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87dd8f70a4da06465d045b9f6a63f1653db2307e930e78492945da9d21260266
|
|
| MD5 |
dda9951cbcd7920e977e0d7aaaf2e5e3
|
|
| BLAKE2b-256 |
d98c2c84fc96b6a0fd45474e3941c7d04ab9bbca133cc58a7db432a520e1ca11
|