The Validate Phone API allows you to check whether a given phone number is valid and return its metadata.
https://api.api-ninjas.com/v1/validatephone
Returns metadata (including whether it is valid) for a given phone number.
number
requiredPhone number to check. If country
is not set, the 3-digit country code prefix needs to be included.
country
optional2-letter ISO-3166 country code the phone number belongs to.
X-Api-Key
requiredAPI Key associated with your account.
https://api.api-ninjas.com/v1/validatephone?number=+12065550100
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
}
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.