This post details the RESTful API method for integrating Phone Validator, which facilitates native access to calling phone lookups. Quickstart Ready to get started? Once you have signed up and created an account try out a quick url search or curl command to query the Phone Validator RESTful API:
https://www.phonevalidator.com/api/phonesearch?apikey={APIKEY}&phone={PHONE}&type=basic,detail,deactivation
Note for security reasons that only secure HTTPS requests are supported.
In order to test the API without incurring charges, please use the following demonstration number: 5551234567
Sending a query using this number will return the following JSON response:
{
"PhoneNumber":"15551234567",
"Cost":0.30,
"SearchDate":"2019-04-02T22:04:01.2579252-07:00",
"StatusCode":"200",
"StatusMessage":"OK",
"PhoneBasic":
{
"PhoneNumber":"15551234567",
"ReportDate":"2019-04-02T22:04:01.2579252-07:00",
"LineType":"CELL PHONE",
"PhoneCompany":"AT&T",
"PhoneLocation":"LOS ANGELES, CA",
"ErrorCode":"",
"ErrorDescription":""
},
"PhoneDetail":
{
"PhoneNumber":"15551234567",
"ReportDate":"2019-04-02T22:04:01.2579252-07:00",
"AreaCodePrefix":"VALID",
"PhoneCompany":"VERIZON WIRELESS",
"IsWireLess":"YES",
"ErrorCode":"",
"ErrorDescription":""
},
"PhoneDeactivation":
{
"PhoneNumber":"15551234567",
"ReportDate":"2019-04-02T22:04:01.2579252-07:00",
"LastDeactivation":true,
"LastDeactivationDate":"2017-11-13",
"LastDeactivationCompany":"VERIZON WIRELESS",
"ErrorCode":"",
"ErrorDescription":""
}
}
Basics
This documentation uses a couple notes and documentation conventions that will be explained in this section.
- Authentication is always required. To simplify the examples, however, the documentation will frequently omit showing the query-string api key parameter.
- Your Api key should not, in any circumstances, be shared with anyone else. Should your key be comprimised, you will need to immediately request a new key, or cancel your account. You are responsible for any costs incurred while accessing the Api with your key.
- The phone number can be in serveral formats and can include the leading 1 but is not required. (For example for you can use 15551234567 or 5551234567, 1-555-123-4567 or 555-123-4567.)
Authentication
All Phone Validator Api requests require authentication, by passing your api key as part of the query string parameters. You can verify you have API access and obtain your key by visiting your account information.
Passing Arguments
There are a few configuration options that you can specify via query-string when making a request to Phone Validator Api.
Query String: apikey
You must authenticate by passing the apikey in the query string. Below you will find an example of authentication using the the apikey parameter within the query string.
https://www.phonevalidator.com/api/phonesearch?apikey={APIKEY}
Query String: phone
The phone parameter can be in serveral formats and can include the leading 1 but is not required. (For example for you can use 15551234567 or 5551234567, 1-555-123-4567 or 555-123-4567.)
https://www.phonevalidator.com/api/phonesearch?apikey={APIKEY}&phone={PHONE}
Query String: type
The type parameter indicates the phone lookup request. There are three types of lookups – basic, detail, and deactivation. Any search combination can be used for the type parameter, and each one should be seperated by a comma. Example for all three would be basic,detail,deactivation.
https://www.phonevalidator.com/api/phonesearch?apikey={APIKEY}&phone={PHONE}&type={TYPE}
Response Formats
All responses are returned in JSON format. Following are examples of each response and corresponding fields returned.
Header Results:
The header result will contain phone number searched, cost for search, search date, status code, and status message.
"PhoneNumber":"15551234567",
"Cost":0.30,
"SearchDate":"2019-04-02T22:04:01.2579252-07:00",
"StatusCode":"200",
"StatusMessage":"OK"
Basic Results:
The basic search will return phone number searched, line type, error code, and error description. Possible values for line type are Cell Phone and Landline. Any error that occurs for basic lookup will be indicated in the basic results.
"PhoneNumber":"15551234567",
"ReportDate":"2019-04-02T22:04:01.2579252-07:00",
"LineType":"CELL PHONE",
"PhoneCompany":"AT&T",
"PhoneLocation":"LOS ANGELES, CA",
"ErrorCode":"",
"ErrorDescription":""
Detail Results:
The detail search will return phone number searched, phone status, carrier name, if wireless, error code, and error description. Any error that occurs for detail lookup will be indicated in the detail results.
"PhoneNumber":"15551234567",
"ReportDate":"2019-04-02T22:04:01.2579252-07:00",
"AreaCodePrefix":"VALID",
"PhoneCompany":"VERIZON WIRELESS",
"IsWireLess":"YES",
"ErrorCode":"",
"ErrorDescription":""
Deactivation Results:
The deactivation search will return phone number searched, if deactivated, deactivated carrier name, deactiveate date, error code, and error description. Any error that occurs for deactivation lookup will be indicated in the detail results.
"PhoneNumber":"15551234567",
"ReportDate":"2019-04-02T22:04:01.2579252-07:00",
"LastDeactivation":true,
"LastDeactivationDate":"2017-11-13",
"LastDeactivationCompany":"VERIZON WIRELESS",
"ErrorCode":"",
"ErrorDescription":""
Status Codes
When making Phone Validator API requests, there are several different HTTP status codes you may receive. If the status code is 200, everything is great. All other status codes indicate an error in processing the request.
200 OK
The request was successful.
500 UNEXPECTED ERROR
An unexpected error has occurred processing phone lookup.
501 BAD REQUEST
The phone number (e.g. format) isn’t valid or is missing.
502 ACCOUNT NOT ACTIVE
The account is no longer active.
503 UNAUTHORIZED
The request was missing authentication or the credentials are not valid.
504 INSUFFICENT FUNDS
Authentication succeeded, but the account does not have enough funds available to complete the request.
505 NOT FOUND
The phone number does not have any phone information available.
FULL CODE :
<?php
$url = 'https://www.phonevalidator.com/api/phonesearch';
$data = array(
'apikey' => 'c8001dec-1b13-497e-89f0-d6beba73d1f4',
'phone' => '4073009727',
'type' => 'basic',
);
$fields = '';
foreach ($data as $key => $value)
{
$fields .= "{$key}={$value}&";
}
$data_string = rtrim($fields, '&');
$endpoint = $url.'?'.$data_string;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $endpoint); //Url together with parameters
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Return data instead printing directly in Browser
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT , 7); //Timeout after 7 seconds
curl_setopt($ch, CURLOPT_USERAGENT , "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
curl_setopt($ch, CURLOPT_HEADER, 0);
$result = curl_exec($ch);
if(curl_errno($ch)) //catch if curl error exists and show it
echo 'Curl error: ' . curl_error($ch);
else
// echo $result;
$json = json_decode($result, true);
print_r($json);
//echo $json['Phone'];
//echo $json['StatusCode'];
//echo $json['StatusMessage'];
$info = curl_getinfo($ch);
//print_r($info);
curl_close($ch);
?>