Phone Validation API
curl --request GET \
--url https://phonevalidation.abstractapi.com/v1import requests
url = "https://phonevalidation.abstractapi.com/v1"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://phonevalidation.abstractapi.com/v1', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://phonevalidation.abstractapi.com/v1",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://phonevalidation.abstractapi.com/v1"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://phonevalidation.abstractapi.com/v1")
.asString();require 'uri'
require 'net/http'
url = URI("https://phonevalidation.abstractapi.com/v1")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"phone": "14152007986",
"valid": true,
"format": {
"international": "+14152007986",
"local": "(415) 200-7986"
},
"country": {
"code": "US",
"name": "United States",
"prefix": "+1"
},
"location": "California",
"type": "mobile",
"carrier": "T-Mobile USA, Inc."
}
Phone Validation API
Abstract API’s Phone Number Validation and Verification API is a fast, lightweight, modern, and RESTful JSON API for determining the validity and other details of phone numbers from over 190 countries.
GET
/
v1
Phone Validation API
curl --request GET \
--url https://phonevalidation.abstractapi.com/v1import requests
url = "https://phonevalidation.abstractapi.com/v1"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://phonevalidation.abstractapi.com/v1', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://phonevalidation.abstractapi.com/v1",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://phonevalidation.abstractapi.com/v1"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://phonevalidation.abstractapi.com/v1")
.asString();require 'uri'
require 'net/http'
url = URI("https://phonevalidation.abstractapi.com/v1")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"phone": "14152007986",
"valid": true,
"format": {
"international": "+14152007986",
"local": "(415) 200-7986"
},
"country": {
"code": "US",
"name": "United States",
"prefix": "+1"
},
"location": "California",
"type": "mobile",
"carrier": "T-Mobile USA, Inc."
}
It’s very simple to use: you only need to submit your API key and a phone number, and the API will respond as assessment of its validity, as well as additional details like the carrier details, line type, region and city details, and more.
This was a successful request, so the valid phone number and details associated with it are returned below:
Getting started
REST
The Phone Number Validation and Verification API, like every Abstract API product, is organized around REST. It is designed to use predictable, resource-oriented URL’s and to use HTTP status codes to indicate errors.HTTPS
The Phone Number Validation and Verification API requires all communications to be secured TLS 1.2 or greater.API Versions
Every Abstract API product is versioned. The Phone Number Validation and Verification API is currently on Version 1.Your API Key
Your API key is your unique authentication key to be used to access Abstract API’s Phone Number Validation and Verification API. Note that each Abstract API product has a unique API key, so you will need different keys to access the Phone Number Validation and Verification and Email Validation APIs, for example. To authenticate your requests, you will need to append your API key to the base URL.Base URL
https://phonevalidation.abstractapi.com/v1/
Validation endpoint
Abstract API’s Phone Number Validation and Verification API simply requires your unique API key and the phone number you’d like to check:https://phonevalidation.abstractapi.com/v1/
? api_key = YOUR_UNIQUE_API_KEY
& phone = 14154582468
{
"phone": "14152007986",
"valid": true,
"format": {
"international": "+14152007986",
"local": "(415) 200-7986"
},
"country": {
"code": "US",
"name": "United States",
"prefix": "+1"
},
"location": "California",
"type": "mobile",
"carrier": "T-Mobile USA, Inc."
}
Request parameters
Your unique API key. Note that each user has unique API keys for each
Abstract API product, so your Phone Validation API key will not work for your IP
Geolocation API, for example.
The country’s ISO code. Add this parameter to indicate the phone number’s country, and the API will append the corresponding country code to its analysis. For instance, add country=US to indicate that the phone number is from the United States.
Response parameters
The API response is returned in a universal and lightweight JSON format.The international format of the submitted phone number. This means appending
the phone number’s country code and a ”+” at the beginning.
The local or national format of the submitted phone number. For example, it
removes any international formatting, such as “+1” in the case of the US.
The country’s two letter ISO 3166-1 alpha-2
code.
The country’s calling code
prefix.
As much location details as are available from our data. This can include the
region, state / province, and in some cases down to the city.
The type of phone number. The possible values are:
Landline, Mobile,
Satellite, Premium, Paging, Special, Toll_Free, and Unknown.Bulk upload (CSV)
Here are some best practices when bulk uploading a CSV file:- Ensure the first column contains the phone numbers to be analyzed.
- Remove any empty rows from the file.
- Include only one phone number per row.
- The maximum file size permitted is 50,000 rows.
Response and error codes
Whenever you make a request that fails for some reason, an error is returned also in the JSON format. The errors include an error code and description, which you can find in detail below.| Code | Type | Details |
|---|---|---|
| 200 | OK | Everything worked as expected. |
| 400 | Bad request | Bad request. |
| 401 | Unauthorized | The request was unacceptable. Typically due to the API key missing or incorrect. |
| 422 | Quota reached | The request was aborted due to insufficient API credits. (Free plans) |
| 429 | Too many requests | The request was aborted due to the number of allowed requests per second being reached. This happens on free plans as requests are limited to 1 per second. |
| 500 | Internal server error | The request could not be completed due to an error on the server side. |
| 503 | Service unavailable | The server was unavailable. |