The format endpoint parses any phone number (international or domestic) and returns comprehensive information including formatted outputs, carrier data, location details, and flag images.
GET /v1/format/:tn
GET /v1/format?tn=:tn
Requires API key via one of:
Authorization: Bearer <key> header (recommended)
X-API-Key header
apiKey query parameter
See Authentication for details.
Parameter Type Required Description tnstring Yes Phone number (telephone number) in any format
Parameter Type Required Description tnstring Yes* Phone number. *Required when not using path parameter. defaultCountrystring No ISO 3166-1 alpha-2 country code (default: US). Used when number has no country code. cachestring 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+13055551234011442087599036+442087599036 (US intl prefix)00442087599036+442087599036 (EU intl prefix)3055551234+13055551234 (with defaultCountry=US)
curl -H "Authorization: Bearer your-api-key" \
"https://api.telco.dev/v1/format/+442087599036"
curl -H "Authorization: Bearer your-api-key" \
"https://api.telco.dev/v1/format/3055551234"
curl -H "Authorization: Bearer your-api-key" \
"https://api.telco.dev/v1/format/02087599036?defaultCountry=GB"
curl -H "Authorization: Bearer your-api-key" \
"https://api.telco.dev/v1/format/+13055551234?cache=false"
{
"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
}
{
"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
}
{
"valid" : false ,
"possible" : false ,
"input" : "invalid"
}
Field Type Description validboolean Whether the number is a valid phone number possibleboolean Whether the number could be valid (correct length/format) inputstring The normalized input after processing countryCodestring Country calling code without + (e.g., 1, 44) countryCallingCodestring Country calling code with + (e.g., +1, +44) countrystring ISO 3166-1 alpha-2 country code (e.g., US, GB) nationalNumberstring National number without country code
Field Type Description npastring Area code (first 3 digits) nxxstring Exchange code (middle 3 digits) nxxxstring Subscriber number (last 4 digits)
Field Type Description formats.e164string E.164 format: +13055551234 formats.internationalstring International format: +1 305 555 1234 formats.nationalstring National format: (305) 555-1234 formats.rfc3966string RFC 3966 URI: tel:+1-305-555-1234
Field Type Description typestring Number type code typeDescriptionstring Human-readable type description
Possible type values:
Type Description FIXED_LINELandline MOBILEMobile FIXED_LINE_OR_MOBILELandline or Mobile TOLL_FREEToll-Free PREMIUM_RATEPremium Rate SHARED_COSTShared Cost VOIPVoIP PERSONAL_NUMBERPersonal Number PAGERPager UANUniversal Access Number VOICEMAILVoicemail
Field Type Description location.rateCenterstring Rate center name (NANP only) location.statestring State/province code (NANP only) location.stateNamestring Full state/province name (NANP only) location.countrystring Country code location.countryNamestring Full country name
Field Type Description carrier.ocnstring Operating Company Number carrier.namestring Carrier name carrier.typestring Carrier type (ILEC, CLEC, WIRELESS, etc.)
Field Type Description flags.countryobject Country flag images flags.stateobject State flag images (US only) flags.*.svgstring SVG image URL flags.*.png.smallstring 48x32 PNG flags.*.png.mediumstring 240x160 PNG flags.*.png.largestring 480x320 PNG
Field Type Description isNonGeographicboolean Whether the number is non-geographic (toll-free, etc.)
{
"error" : "Bad Request" ,
"message" : "Invalid defaultCountry: XX. Must be a valid ISO 3166-1 alpha-2 country code."
}
{
"error" : "unauthorized" ,
"message" : "API key required."
}
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 }` );
}
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' ] } " )