DEV Community

Alexey D
Alexey D

Posted on

How to Validate Phone Numbers in Any Country with a Free API

Bad phone numbers kill SMS campaigns and bloat your database. Here's a free API that fixes this in one call.

The Problem

  • Users enter 123456 or +1 (555) 000-0000 (fake)
  • You send SMS to invalid numbers → wasted money
  • No way to know if it's mobile vs landline vs VoIP

The Solution: Phone Validator Pro API

One POST request → you get everything:

import requests

r = requests.post(
    "https://phonevalidatorpro.p.rapidapi.com/validate",
    json={"phone": "+12125552000", "country_code": "US"},
    headers={"X-RapidAPI-Key": "YOUR_KEY", "Content-Type": "application/json"}
)
print(r.json())
Enter fullscreen mode Exit fullscreen mode

Response:

{
  "is_valid": true,
  "international_format": "+1 212-555-2000",
  "e164_format": "+12125552000",
  "country": "United States",
  "carrier": "AT&T",
  "line_type": "MOBILE",
  "timezones": ["America/New_York"]
}
Enter fullscreen mode Exit fullscreen mode

What you get

Field Description
is_valid true/false
e164_format Standard format for SMS APIs (Twilio, etc.)
line_type MOBILE / FIXED_LINE / VOIP / TOLL_FREE
country Full country name
carrier Network operator
timezones All timezones for that number

Batch validation (up to 50 numbers)

numbers = [
    {"phone": "+79161234567", "country_code": "RU"},
    {"phone": "+447911123456", "country_code": "GB"},
    {"phone": "+33612345678", "country_code": "FR"}
]

r = requests.post(
    "https://phonevalidatorpro.p.rapidapi.com/batch",
    json=numbers,
    headers={"X-RapidAPI-Key": "YOUR_KEY", "Content-Type": "application/json"}
)
Enter fullscreen mode Exit fullscreen mode

JavaScript example

const res = await fetch("https://phonevalidatorpro.p.rapidapi.com/validate", {
  method: "POST",
  headers: {
    "X-RapidAPI-Key": "YOUR_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({ phone: "+447911123456", country_code: "GB" })
});
const data = await res.json();
console.log(data.line_type); // "MOBILE"
Enter fullscreen mode Exit fullscreen mode

Use cases

  • Registration forms — reject fake/invalid numbers instantly
  • SMS campaigns — clean your list before sending
  • CRM enrichment — tag contacts by country and line type
  • Fraud prevention — flag VOIP numbers (often used by bots)
  • International apps — normalize formats across 200+ countries

Pricing

Plan Price Rate limit
BASIC Free 50 req/hr
PRO $9.99/mo 1,000 req/hr
ULTRA $29.99/mo 10,000 req/hr

Try it free — no credit card: Phone Validator Pro on RapidAPI

Top comments (0)