How to Build a Reverse Phone Lookup App in Python and Node.js

In today’s hyper-connected world, businesses and developers often need to identify who is calling or texting. Whether it is to personalize user onboarding, verify user identities, filter out spam, or enrich CRM contacts, a reverse phone lookup API is a crucial tool.

In this tutorial, we will show you how to build a simple reverse phone lookup application using Python and Node.js. We will leverage the ProWebLook Caller ID API, a highly accurate and low-latency API that returns owner names, carrier information, location, line types, and timezone details.

The ProWebLook Caller ID API Endpoint

ProWebLook provides a simple REST API endpoint that allows you to query caller identity details using a phone number and an API key.

  • Base URL: https://lookup.proweblook.com/api/v1/calleridvalidation
  • HTTP Method: GET
  • Query Parameters:
    • phone_number: The target phone number in E.164 format (digits only, e.g., 14155552671).
    • api_key: Your unique ProWebLook API key.

1. Quick cURL Example

Before diving into Python or Node.js code, you can test the API directly from your terminal using cURL:

curl -X GET "https://lookup.proweblook.com/api/v1/calleridvalidation?phone_number=14155552671&api_key=YOUR_API_KEY"

Example JSON Response

When you make a successful request, the API returns a structured JSON payload:

{
  "status": "VALID_CONFIRMED",
  "name": "John Doe",
  "line_type": "mobile",
  "carrier": "AT&T Mobility",
  "location": "San Francisco, CA",
  "formatinternational": "+1 415-555-2671",
  "formatnational": "(415) 555-2671",
  "countrycodenum": "1",
  "timezone": [
    "America/Los_Angeles"
  ]
}

2. Implementing in Node.js

If you are building your backend in JavaScript, you can implement the reverse phone lookup using Node.js’s native fetch API.

Here is a clean example:

const https = require('https');

// Configuration
const apiKey = 'YOUR_API_KEY';
const phoneNumber = '14155552671'; // E.164 format, digits only
const url = `https://lookup.proweblook.com/api/v1/calleridvalidation?phone_number=\${phoneNumber}&api_key=\${apiKey}`;

// Perform the API Request
fetch(url)
  .then(response => {
    if (!response.ok) {
      throw new Error(`HTTP error! Status: \${response.status}`);
    }
    return response.json();
  })
  .then(data => {
    console.log('--- Caller ID Details ---');
    console.log(`Name: \${data.name || 'Unknown'}`);
    console.log(`Line Type: \${data.line_type || 'N/A'}`);
    console.log(`Carrier: \${data.carrier || 'N/A'}`);
    console.log(`Location: \${data.location || 'N/A'}`);
    console.log(`Format International: \${data.formatinternational}`);
    console.log(`Time Zone: \${data.timezone ? data.timezone.join(', ') : 'N/A'}`);
  })
  .catch(error => {
    console.error('Error fetching caller info:', error.message);
  });

3. Implementing in Python

For Python developers, the popular requests library makes fetching caller information incredibly straightforward.

import requests

def lookup_phone_number(phone_number, api_key):
    # API Endpoint URL
    url = "https://lookup.proweblook.com/api/v1/calleridvalidation"
    
    # Query Parameters
    params = {
        "phone_number": phone_number,
        "api_key": api_key
    }
    
    try:
        response = requests.get(url, params=params, timeout=10)
        response.raise_for_status() # Raise exception for 4xx/5xx status codes
        
        data = response.json()
        
        print("--- Caller ID Details ---")
        print(f"Name: {data.get('name', 'Unknown')}")
        print(f"Line Type: {data.get('line_type', 'N/A')}")
        print(f"Carrier: {data.get('carrier', 'N/A')}")
        print(f"Location: {data.get('location', 'N/A')}")
        print(f"Format International: {data.get('formatinternational', 'N/A')}")
        print(f"Time Zone: {', '.join(data.get('timezone', []))}")
        
    except requests.exceptions.RequestException as e:
        print(f"An error occurred: {e}")

# Configuration
API_KEY = "YOUR_API_KEY"
PHONE = "14155552671" # E.164 format, digits only

if __name__ == "__main__":
    lookup_phone_number(PHONE, API_KEY)

Wrapping Up

Building caller ID features into your application doesn’t require complex setups or managing massive telecom databases. With just a few lines of Python or Node.js code, you can easily query the ProWebLook API to get real-time owner, carrier, and location insights.

Ready to start validating phone numbers and identifying callers?

👉 Sign up at ProWebLook to get your API key today and start querying with free credits!

Leave a Comment

Your email address will not be published. Required fields are marked *

Exit mobile version