MarkdownCopies this page as Markdown, ready to paste into an AI assistant.
Phone API
2 Phone endpoints behind one key, priced in credits per call and routed to the cheapest healthy source.
On this page
Validation · 2 endpoints · from 1 credit per call
Endpoints
- POSTPhone Intelligence
/v1/run/phone.intelligenceValidates a phone number and returns its E.164, national and international formats, country, calling code and line type.1 creditper call - POSTPhone Number Type
/v1/run/phone.number_typeClassifies a phone number as mobile, landline, VoIP, toll-free, premium-rate and so on from numbering-plan data, with a validity check.1 creditper call
Calling them
Every endpoint on this page is one POST to https://api.primaryapi.com/v1/run/{sku} with your API key and a JSON body. Responses share one envelope, so code written for one endpoint handles the others. For example, phone.intelligence:
curl -sS -X POST "https://api.primaryapi.com/v1/run/phone.intelligence" \
-H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"phone_number":"+14155552671"}'const res = await fetch('https://api.primaryapi.com/v1/run/phone.intelligence', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.PRIMARYAPI_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
phone_number: '+14155552671',
}),
});
const body = await res.json();
if (!res.ok) throw new Error(`${body.code}: ${body.error}`);
// found:false is a successful answer ("does not exist"), not an error
console.log(body.output.found ? body.output.data : body.output.reason, body.credits);import os
import requests
res = requests.post(
"https://api.primaryapi.com/v1/run/phone.intelligence",
headers={"Authorization": f"Bearer {os.environ['PRIMARYAPI_API_KEY']}"},
json={
"phone_number": "+14155552671",
},
timeout=60,
)
body = res.json()
if not res.ok:
raise RuntimeError(f"{body['code']}: {body['error']}")
# found=False is a successful answer ("does not exist"), not an error
print(body["output"]["data"] if body["output"]["found"] else body["output"]["reason"], body["credits"])New to PrimaryAPI? Start with the Quickstart, then read Making requests.