API Code Examples

Code examples for integrating VeriRoute Intel APIs into your telecom, SaaS, or enterprise applications.

Sample Requests

Code examples and SDK documentation for various programming languages to help you integrate with VeriRoute Intel APIs quickly and efficiently.

Language Support

🐍 Python
📜 JavaScript
🐘 PHP
💻 cURL

Best Practices

🔐 Authentication

Always include your API key in the Authorization header as "Bearer YOUR_API_KEY" for secure access.

⚡ Error Handling

Implement proper error handling and retry logic for robust integrations, especially for rate limits and network issues.

📊 Rate Limiting

Monitor your usage and implement exponential backoff to handle rate limits gracefully in production environments.

🔍 Data Validation

Validate phone numbers before sending requests to ensure proper E.164 or 10-digit US format compliance.

REST API Code Examples

🏷️ CNAM API

Python

import requests

headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}

data = {"phone_number": "15555550123"}
response = requests.post(
    "https://api-service.verirouteintel.io/api/v1/cnam/lookup", 
    headers=headers, 
    json=data
)
result = response.json()
print(f"CNAM: {result['cnam']}")

cURL

curl -X POST https://api-service.verirouteintel.io/api/v1/cnam/lookup \\
  -H "Authorization: Bearer YOUR_API_KEY" \\
  -H "Content-Type: application/json" \\
  -d '{"phone_number": "15555550123"}'

JavaScript

const response = await fetch('https://api-service.verirouteintel.io/api/v1/cnam/lookup', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    phone_number: '15555550123'
  })
});

const result = await response.json();
console.log('CNAM:', result.cnam);

PHP

 'https://api-service.verirouteintel.io/api/v1/cnam/lookup',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => json_encode(array('phone_number' => '15555550123')),
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer YOUR_API_KEY',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);
curl_close($curl);

$result = json_decode($response, true);
echo "CNAM: " . $result['cnam'];
?>

🔄 LRN API

Python

import requests

headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}

data = {"phone_number": "15555550123"}
response = requests.post(
    "https://api-service.verirouteintel.io/api/v1/lrn/lookup", 
    headers=headers, 
    json=data
)
result = response.json()
print(f"LRN: {result['lrn']}", f"Carrier: {result['carrier']}")

cURL

curl -X POST https://api-service.verirouteintel.io/api/v1/lrn/lookup \\
  -H "Authorization: Bearer YOUR_API_KEY" \\
  -H "Content-Type: application/json" \\
  -d '{"phone_number": "15555550123"}'

📱 Messaging Provider API

Python

import requests

headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}

data = {"phone_number": "15555550123"}
response = requests.post(
    "https://api-service.verirouteintel.io/api/v1/messaging/lookup", 
    headers=headers, 
    json=data
)
result = response.json()
print(f"Messaging Provider: {result['messaging_provider']}")

cURL

curl -X POST https://api-service.verirouteintel.io/api/v1/messaging/lookup \\
  -H "Authorization: Bearer YOUR_API_KEY" \\
  -H "Content-Type: application/json" \\
  -d '{"phone_number": "15555550123"}'

🔍 Number Intelligence API

Python

import requests

headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}

data = {"phone_number": "15555550123"}
response = requests.post(
    "https://api-service.verirouteintel.io/api/v1/lookup", 
    headers=headers, 
    json=data
)
result = response.json()
print(f"Carrier: {result['carrier']}", f"LRN: {result['lrn']}", f"CNAM: {result['cnam']}")

GraphQL API Code Examples

CNAM Lookup

Python

import requests

query = """
query LookupCnam($phoneNumber: String!) {
  lookupCnam(phoneNumber: $phoneNumber) {
    phoneNumber
    cnam
    success
    error
  }
}"""

variables = {"phoneNumber": "15555550123"}

response = requests.post(
    "https://api-service.verirouteintel.io/graphql",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={"query": query, "variables": variables}
)

result = response.json()
print(result['data']['lookupCnam']['cnam'])

JavaScript

const query = `
  query LookupCnam($phoneNumber: String!) {
    lookupCnam(phoneNumber: $phoneNumber) {
      phoneNumber
      cnam
      success
      error
    }
  }
`;

const variables = { phoneNumber: '15555550123' };

const response = await fetch('https://api-service.verirouteintel.io/graphql', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ query, variables })
});

const result = await response.json();
console.log(result.data.lookupCnam.cnam);

LRN Lookup

Python

query = """
query LookupLrn($phoneNumber: String!) {
  lookupLrn(phoneNumber: $phoneNumber) {
    phoneNumber
    lrn
    carrier
    success
    error
  }
}"""

variables = {"phoneNumber": "15555550123"}

response = requests.post(
    "https://api-service.verirouteintel.io/graphql",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={"query": query, "variables": variables}
)

result = response.json()
print(f"LRN: {result['data']['lookupLrn']['lrn']}")

Messaging Provider Lookup

Python

query = """
query LookupMessagingProvider($phoneNumber: String!) {
  lookupMessagingProvider(phoneNumber: $phoneNumber) {
    phoneNumber
    messagingProvider
    success
    error
  }
}"""

variables = {"phoneNumber": "15555550123"}

response = requests.post(
    "https://api-service.verirouteintel.io/graphql",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={"query": query, "variables": variables}
)

result = response.json()
print(f"Messaging Provider: {result['data']['lookupMessagingProvider']['messagingProvider']}")