Code Examples

The Veriphone API is a simple REST service — no SDK required. Use any HTTP client in any language. Here are ready-to-use examples you can copy and paste into your project.

Validate a Phone Number

A single GET request is all you need. Replace YOUR_API_KEY with your actual key from the control panel.

curl "https://api.veriphone.io/v2/verify?phone=%2B4915123577723" \
  -H "Authorization: Bearer YOUR_API_KEY"
const res = await fetch(
  'https://api.veriphone.io/v2/verify?phone=%2B4915123577723',
  { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }
);
const data = await res.json();
console.log(data.phone_valid, data.carrier);
import requests

res = requests.get(
    'https://api.veriphone.io/v2/verify',
    params={'phone': '+4915123577723'},
    headers={'Authorization': 'Bearer YOUR_API_KEY'}
)
data = res.json()
print(data['phone_valid'], data['carrier'])
$response = file_get_contents(
  'https://api.veriphone.io/v2/verify?phone=%2B4915123577723',
  false,
  stream_context_create(['http' => [
    'header' => 'Authorization: Bearer YOUR_API_KEY'
  ]])
);
$data = json_decode($response, true);
echo $data['phone_valid'], $data['carrier'];
require 'net/http'
require 'json'

uri = URI('https://api.veriphone.io/v2/verify?phone=%2B4915123577723')
req = Net::HTTP::Get.new(uri)
req['Authorization'] = 'Bearer YOUR_API_KEY'

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
data = JSON.parse(res.body)
puts data['phone_valid'], data['carrier']
req, _ := http.NewRequest("GET",
  "https://api.veriphone.io/v2/verify?phone=%2B4915123577723", nil)
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")

res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()

var data map[string]interface{}
json.NewDecoder(res.Body).Decode(&data)
fmt.Println(data["phone_valid"], data["carrier"])
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.veriphone.io/v2/verify?phone=%2B4915123577723"))
    .header("Authorization", "Bearer YOUR_API_KEY")
    .build();

HttpResponse<String> response = HttpClient.newHttpClient()
    .send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_API_KEY");

var json = await client.GetStringAsync(
  "https://api.veriphone.io/v2/verify?phone=%2B4915123577723"
);
Console.WriteLine(json);

Response

JSON
{
  "status": "success",
  "phone": "+4915123577723",
  "phone_valid": true,
  "phone_type": "mobile",
  "phone_region": "Germany",
  "country": "Germany",
  "country_code": "DE",
  "country_prefix": "49",
  "international_number": "+49 1512 3577723",
  "local_number": "01512 3577723",
  "e164": "+4915123577723",
  "carrier": "T-Mobile"
}

Error Handling

The API returns standard HTTP status codes. Check the response status and handle errors accordingly.

const res = await fetch(
  'https://api.veriphone.io/v2/verify?phone=%2B4915123577723',
  { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }
);

if (!res.ok) {
  const err = await res.json();
  console.error(err.message); // "Human-readable error description"
} else {
  const data = await res.json();
  console.log(data.phone_valid);
}
import requests

res = requests.get(
    'https://api.veriphone.io/v2/verify',
    params={'phone': '+4915123577723'},
    headers={'Authorization': 'Bearer YOUR_API_KEY'}
)

if res.status_code != 200:
    print('Error:', res.json()['message'])
else:
    data = res.json()
    print(data['phone_valid'])
That's it
No SDK to install, no dependencies to manage. Every language with an HTTP client works out of the box. See the API Reference for the full endpoint spec.