Phone Number Format
Parse and format any international phone number with carrier, location, and flag data
The format endpoint parses any phone number (international or domestic) and returns comprehensive information including formatted outputs, carrier data, location details, and flag images.
Endpoint
GET /v1/format/:tn
GET /v1/format?tn=:tn
Authentication
Requires API key via one of:
Authorization: Bearer <key> header (recommended)
X-API-Key header
apiKey query parameter
See Authentication for details.
Parameters
Path Parameters
| Parameter | Type | Required | Description |
|---|
tn | string | Yes | Phone number (telephone number) in any format |
Query Parameters
| Parameter | Type | Required | Description |
|---|
tn | string | Yes* | Phone number. *Required when not using path parameter. |
defaultCountry | string | No | ISO 3166-1 alpha-2 country code (default: US). Used when number has no country code. |
cache | string | No | Set to false to bypass cache and force fresh lookup. |
The endpoint accepts phone numbers in many formats:
| Input | Normalized To |
|---|
+442087599036 | +442087599036 |
+1 (305) 555-1234 | +13055551234 |
011442087599036 | +442087599036 (US intl prefix) |
00442087599036 | +442087599036 (EU intl prefix) |
3055551234 | +13055551234 (with defaultCountry=US) |
Request Examples
International Number
curl -H "Authorization: Bearer your-api-key" \
"https://api.telco.dev/v1/format/+442087599036"
US Number
curl -H "Authorization: Bearer your-api-key" \
"https://api.telco.dev/v1/format/3055551234"
With Default Country
curl -H "Authorization: Bearer your-api-key" \
"https://api.telco.dev/v1/format/02087599036?defaultCountry=GB"
Force Fresh Lookup
curl -H "Authorization: Bearer your-api-key" \
"https://api.telco.dev/v1/format/+13055551234?cache=false"
Response
Success Response - US Number (200 OK)
{
"valid": true,
"possible": true,
"input": "+13055551234",
"countryCode": "1",
"countryCallingCode": "+1",
"country": "US",
"nationalNumber": "3055551234",
"npa": "305",
"nxx": "555",
"nxxx": "1234",
"formats": {
"e164": "+13055551234",
"international": "+1 305 555 1234",
"national": "(305) 555-1234",
"rfc3966": "tel:+1-305-555-1234"
},
"type": "FIXED_LINE_OR_MOBILE",
"typeDescription": "Landline or Mobile",
"location": {
"rateCenter": "MIAMI",
"state": "FL",
"stateName": "Florida",
"country": "US",
"countryName": "United States"
},
"carrier": {
"ocn": "9740",
"name": "BELLSOUTH TELECOMM INC DBA SOUTHERN BELL TEL & TEL",
"type": "ILEC"
},
"flags": {
"country": {
"name": "United States",
"abbreviation": "US",
"svg": "https://raw.githubusercontent.com/dodotdev/telco-dev-flags/master/flags/world/us/us.svg",
"png": {
"small": "https://raw.githubusercontent.com/dodotdev/telco-dev-flags/master/flags/world/us/us_48x32.png",
"medium": "https://raw.githubusercontent.com/dodotdev/telco-dev-flags/master/flags/world/us/us_240x160.png",
"large": "https://raw.githubusercontent.com/dodotdev/telco-dev-flags/master/flags/world/us/us_480x320.png"
}
},
"state": {
"name": "Florida",
"abbreviation": "FL",
"svg": "https://raw.githubusercontent.com/dodotdev/telco-dev-flags/master/flags/us/fl/fl.svg",
"png": {
"small": "https://raw.githubusercontent.com/dodotdev/telco-dev-flags/master/flags/us/fl/fl_48x32.png",
"medium": "https://raw.githubusercontent.com/dodotdev/telco-dev-flags/master/flags/us/fl/fl_240x160.png",
"large": "https://raw.githubusercontent.com/dodotdev/telco-dev-flags/master/flags/us/fl/fl_480x320.png"
}
}
},
"isNonGeographic": false
}
Success Response - International Number (200 OK)
{
"valid": true,
"possible": true,
"input": "+442087599036",
"countryCode": "44",
"countryCallingCode": "+44",
"country": "GB",
"nationalNumber": "2087599036",
"formats": {
"e164": "+442087599036",
"international": "+44 20 8759 9036",
"national": "020 8759 9036",
"rfc3966": "tel:+44-20-8759-9036"
},
"type": "FIXED_LINE",
"typeDescription": "Landline",
"location": {
"country": "GB",
"countryName": "United Kingdom"
},
"flags": {
"country": {
"name": "United Kingdom",
"abbreviation": "GB",
"svg": "https://raw.githubusercontent.com/dodotdev/telco-dev-flags/master/flags/world/gb/gb.svg",
"png": {
"small": "https://raw.githubusercontent.com/dodotdev/telco-dev-flags/master/flags/world/gb/gb_48x32.png",
"medium": "https://raw.githubusercontent.com/dodotdev/telco-dev-flags/master/flags/world/gb/gb_240x160.png",
"large": "https://raw.githubusercontent.com/dodotdev/telco-dev-flags/master/flags/world/gb/gb_480x320.png"
}
}
},
"isNonGeographic": false
}
Invalid Number Response (200 OK)
{
"valid": false,
"possible": false,
"input": "invalid"
}
Response Fields
Core Fields
| Field | Type | Description |
|---|
valid | boolean | Whether the number is a valid phone number |
possible | boolean | Whether the number could be valid (correct length/format) |
input | string | The normalized input after processing |
countryCode | string | Country calling code without + (e.g., 1, 44) |
countryCallingCode | string | Country calling code with + (e.g., +1, +44) |
country | string | ISO 3166-1 alpha-2 country code (e.g., US, GB) |
nationalNumber | string | National number without country code |
NANP Fields (US/Canada only)
| Field | Type | Description |
|---|
npa | string | Area code (first 3 digits) |
nxx | string | Exchange code (middle 3 digits) |
nxxx | string | Subscriber number (last 4 digits) |
| Field | Type | Description |
|---|
formats.e164 | string | E.164 format: +13055551234 |
formats.international | string | International format: +1 305 555 1234 |
formats.national | string | National format: (305) 555-1234 |
formats.rfc3966 | string | RFC 3966 URI: tel:+1-305-555-1234 |
Number Type
| Field | Type | Description |
|---|
type | string | Number type code |
typeDescription | string | Human-readable type description |
Possible type values:
| Type | Description |
|---|
FIXED_LINE | Landline |
MOBILE | Mobile |
FIXED_LINE_OR_MOBILE | Landline or Mobile |
TOLL_FREE | Toll-Free |
PREMIUM_RATE | Premium Rate |
SHARED_COST | Shared Cost |
VOIP | VoIP |
PERSONAL_NUMBER | Personal Number |
PAGER | Pager |
UAN | Universal Access Number |
VOICEMAIL | Voicemail |
Location
| Field | Type | Description |
|---|
location.rateCenter | string | Rate center name (NANP only) |
location.state | string | State/province code (NANP only) |
location.stateName | string | Full state/province name (NANP only) |
location.country | string | Country code |
location.countryName | string | Full country name |
Carrier (NANP only)
| Field | Type | Description |
|---|
carrier.ocn | string | Operating Company Number |
carrier.name | string | Carrier name |
carrier.type | string | Carrier type (ILEC, CLEC, WIRELESS, etc.) |
Flags
| Field | Type | Description |
|---|
flags.country | object | Country flag images |
flags.state | object | State flag images (US only) |
flags.*.svg | string | SVG image URL |
flags.*.png.small | string | 48x32 PNG |
flags.*.png.medium | string | 240x160 PNG |
flags.*.png.large | string | 480x320 PNG |
| Field | Type | Description |
|---|
isNonGeographic | boolean | Whether the number is non-geographic (toll-free, etc.) |
Error Responses
Invalid Country Code (400)
{
"error": "Bad Request",
"message": "Invalid defaultCountry: XX. Must be a valid ISO 3166-1 alpha-2 country code."
}
Unauthorized (401)
{
"error": "unauthorized",
"message": "API key required."
}
Code Examples
JavaScript
async function formatNumber(number, options = {}) {
const params = new URLSearchParams();
if (options.defaultCountry) params.set('defaultCountry', options.defaultCountry);
if (options.cache === false) params.set('cache', 'false');
const url = `https://api.telco.dev/v1/format/${encodeURIComponent(number)}?${params}`;
const response = await fetch(url, {
headers: {
"Authorization": `Bearer ${process.env.TELCO_API_KEY}`
}
});
return response.json();
}
// Usage
const result = await formatNumber("+442087599036");
if (result.valid) {
console.log(`Country: ${result.location.countryName}`);
console.log(`International: ${result.formats.international}`);
console.log(`Flag: ${result.flags.country.svg}`);
}
Python
import requests
import os
from urllib.parse import quote
def format_number(number, default_country=None, use_cache=True):
params = {}
if default_country:
params['defaultCountry'] = default_country
if not use_cache:
params['cache'] = 'false'
response = requests.get(
f"https://api.telco.dev/v1/format/{quote(number)}",
params=params,
headers={"Authorization": f"Bearer {os.environ['TELCO_API_KEY']}"}
)
return response.json()
# Usage
result = format_number("+442087599036")
if result.get('valid'):
print(f"Country: {result['location']['countryName']}")
print(f"International: {result['formats']['international']}")
print(f"Flag: {result['flags']['country']['svg']}")