Validate Phone API

The Validate Phone API allows you to check whether a given phone number is valid and return its metadata.

/v1/validatephone GET

https://api.api-ninjas.com/v1/validatephone

Returns metadata (including whether it is valid) for a given phone number.


Parameters

  • number  required

    Phone number to check. If country is not set, the 3-digit country code prefix needs to be included.

  • country  optional

    2-letter ISO-3166 country code the phone number belongs to.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Sample Request Live Demo!

number
https://api.api-ninjas.com/v1/validatephone?number=+12065550100

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON
1 2 3 4 5 6 7 8 9 10 11 12 13 { "is_valid": true, "is_formatted_properly": true, "country": "United States", "location": "Washington State", "timezones": [ "America/Los_Angeles" ], "format_national": "(206) 555-0100", "format_international": "+1 206-555-0100", "format_e164": "+12065550100", "country_code": 1 }

Code Examples

1 2 3 4 5 6 7 8 9 import requests number = '+12065550100' api_url = 'https://api.api-ninjas.com/v1/validatephone?number={}'.format(number) response = requests.get(api_url, headers={'X-Api-Key': 'YOUR_API_KEY'}) if response.status_code == requests.codes.ok: print(response.text) else: print("Error:", response.status_code, response.text)

If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.