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](https://genderapi.io) 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:

```bash
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.0.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.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for genderapi_phone_validator-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f343673c1747aa5231edda2904cb5eadfd71de6814fe7fbda2277204269d2efb
MD5 3e938975d11eee3859a5be0981cb058b
BLAKE2b-256 6ab645f47f33ea04fb176c436f66e85949a22a0375d68438f533870c8fc3e945

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for genderapi_phone_validator-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 289b4ef279f6c3317f4eb01109940a4452ed4d222efecebfe76e2ade7783ca7e
MD5 48e2224c2ca5ab63d9c49274fe7fd175
BLAKE2b-256 34f220b594b0d629bf3338da2efcebee5b7926664f81be61635d954941b47393

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