Skip to main content

Validate Phone Numbers using NumLookupAPI

Project description

Phone Number Validator

The Phone Number Validator package provides a simple way to validate phone numbers using the NumLookupAPI.

Installation

You can install the package using pip:

pip install phone-number-validator

Usage

To use the package, you must first obtain an API key from NumLookupAPI. Once you have an API key, you can create a PhoneNumberValidator instance and use its validate method to validate a phone number:

from phone_number_validator.validator import PhoneNumberValidator

validator = PhoneNumberValidator(api_key="YOUR_API_KEY")

# Example 1: Valid phone number without country code
is_valid1 = validator.validate("+16502530000")
print(is_valid1)  # Returns True

# Example 2: Valid phone number with country code
is_valid2 = validator.validate("6502530000", "US")
print(is_valid2)  # Returns True

# Example 3: Invalid phone number without country code
is_valid3 = validator.validate("+11234567890")
print(is_valid3)  # Returns False

# Example 4: Invalid phone number with country code
is_valid4 = validator.validate("1234567890", "US")
print(is_valid4)  # Returns False

The validate method takes a phone number and an optional country code as arguments. If the phone number is valid, the method returns True. If the phone number is invalid, the method returns False.

If the API call fails for any reason, the method raises an HTTPError exception.

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

phone_number_validator-1.0.2.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

phone_number_validator-1.0.2-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: phone_number_validator-1.0.2.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.1 CPython/3.11.0 Windows/10

File hashes

Hashes for phone_number_validator-1.0.2.tar.gz
Algorithm Hash digest
SHA256 ed0cc32e45b8416b998e130e9194aadeb84d65b56a36a60e2c3d6d0f597fc743
MD5 803ba2bd5e913e1827a48c7b298e0c33
BLAKE2b-256 1360eee490afadec7753e7ea3e4c5c93d6e8af23c70d71f9bddb37179222ea54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phone_number_validator-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fdd31c04e50856024576bc8f5c0e23586684773e1179123f78164c0199fa8d5b
MD5 a64e5c309560751a5a42d19b2c4e9cfa
BLAKE2b-256 be7db2c183bf25e1b88e7171eef7902cee93dfc43b219a4405bfca20a4bfb801

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page