Lightweight and efficient US phone number carrier lookup tool with bilingual interface and fast batch query support
- Added geographic location information (city, state) display in query results
- Added port status and porting date information display
- Optimized carrier name display using more accurate spid_carrier_name
- Enhanced batch query results display for consistency with single number query
- Enhanced Virtual Number Identification: Added intelligent identification for 38 common virtual number providers
- Improved UI Display: Added specific labeling for virtual number providers in query results
- Enhanced CSV Export: Added "is_virtual" column to batch query results
- Fixed Carrier Type Detection: Corrected the issue where number types weren't properly identified
- Program completely restructured, now supports dual API providers: Telnyx and Twilio
- Users can choose to use one or both providers as needed
- Added provider switching functionality, easily switch in the main menu
- Optimized system information display, more accurately showing OS and processor information
- Improved error handling and internationalization support
RealCarrier is a professional US phone number status query system that provides essential support for communication service providers, anti-fraud systems, and marketing compliance. Through a clean interface and powerful features, it helps users quickly obtain carrier information, number type, and local number portability status.
π Core Principles
Local Number Portability is a service mandated by US telecommunications regulations that allows users to retain their original phone numbers when changing carriers. Since the Telecommunications Act of 1996, this service has become the foundation of the US telecommunications market competition, with the NPAC database recording over 600 million number transfers.
When a number is transferred, its routing information is updated while the original allocation information remains unchanged, creating challenges in identifying the real carrier. For example, a number originally assigned to AT&T may now be serviced by T-Mobile.
| Type | Description |
|---|---|
| Physical Numbers | Traditional phone numbers associated with actual SIM cards and physical devices, provided by traditional carriers (AT&T, Verizon, T-Mobile, etc.) |
| Virtual Numbers | Numbers provided through VoIP services, not dependent on specific physical locations or devices, offered by virtual operators (Twilio, Bandwidth, Telnyx, etc.) |
Distinguishing between these two types is essential for identifying potential fraudulent activities, verifying user identities, and ensuring communication compliance.
π API Providers
RealCarrier supports two leading telecommunications API providers:
- Telnyx: A global communications platform that provides direct access to the NPAC database, offering the most accurate number portability information
- Twilio: A world-leading communications API provider whose Lookup API offers phone number verification and carrier information query services
Special Notice: the IP address used during Telnyx registration and the payment method (credit card/PayPal) must originate from the same country. For example, if you register with a Singapore IP and pay with a US PayPal account, your registration will be rejected. However, if you register with a US IP and use a US PayPal account, it will not be rejected.
{
"country_code": "US",
"national_format": "(406) XXX-XXX",
"phone_number": "+1406XXXXXXX",
"fraud": null,
"carrier": {
"mobile_country_code": "",
"mobile_network_code": "",
"name": "T-MOBILE USA, INC.",
"type": "mobile",
"error_code": null,
"normalized_carrier": "T-Mobile USA"
},
"caller_name": {
"caller_name": "WIRELESS CALLER",
"error_code": null
},
"nnid_override": null,
"portability": {
"lrn": null,
"ported_status": "",
"ported_date": "",
"ocn": "6034",
"line_type": "mobile",
"spid": "",
"spid_carrier_name": "SPRINT SPECTRUM L.P.- MT",
"spid_carrier_type": "",
"altspid": "",
"altspid_carrier_name": "",
"altspid_carrier_type": "",
"city": "MISSOULA",
"state": "Montana"
},
"valid_number": true,
"record_type": "number_lookup"
}π Telnyx Number Lookup API Guide
This guide provides essential information for developers looking to integrate the Telnyx Number Lookup API into the RealCarrier project.
-
Create a Telnyx Account
- Sign up at Telnyx.com
- Complete the Know Your Customer (KYC) verification process
- Fund your account with the minimum required deposit
-
API Key Access
- Navigate to the API Keys section in your Telnyx Portal
- Generate a new API key for your application
- Store this key securely as it will be needed for all API requests
-
IP Compatibility Note
- Ensure that the IP address used during registration matches the country of your payment method
The Number Lookup API provides detailed information about phone numbers in the United States, with particular emphasis on:
-
Carrier Information
- Current carrier details
- Line type (mobile, landline, VoIP)
- Mobile country and network codes (when applicable)
-
Portability Data
- Local Number Portability (LNP) status
- Original carrier information via SPID
- Port date (when a number has been transferred)
- OCN (Operating Company Number)
-
Geographic Details
- City and state information
- Rate center data
-
Optional Features
- Caller name information
- Fraud risk assessment
- Additional carrier details
The API returns a JSON response with the following key sections:
-
Basic Number Information
country_code: The country code (e.g., "US")national_format: Formatted display of the numberphone_number: The full E.164 format numbervalid_number: Boolean indicating number validity
-
Carrier Section
name: The carrier's official namenormalized_carrier: A standardized version of the carrier nametype: The line type (mobile, landline, voip)
-
Portability Section
ported_status: Indicates if the number has been portedported_date: Date of the most recent portspid_carrier_name: The original carrier name (most accurate)cityandstate: Geographic location
-
Error Handling
- Implement robust error handling for API rate limits
- Account for potential network connectivity issues
- Handle invalid phone number formats gracefully
-
Caching Strategy
- Implement a local cache to store lookup results
- Set appropriate expiration times for cached data
- Consider database storage for frequently queried numbers
-
Virtual Number Detection
- Look for
carrier.typevalue of "voip" - Check carrier names against the virtual provider database
- Look for
| Feature | Description |
|---|---|
| π API Key Management | Securely store and manage your Telnyx and Twilio API keys |
| π Dual API Providers | Support for both Telnyx and Twilio, with flexible selection based on user needs |
| π Single Number Query | Quickly query carrier information for a single phone number |
| π Batch Query | Efficiently query multiple numbers from a CSV file |
| πΎ Smart Caching | Multi-level caching strategy to reduce API calls and lower costs |
| π Bilingual Interface | Seamless switching between Chinese and English to meet different user needs |
| π» Convenient CLI | User-friendly CLI interface and advanced command-line tools |
π₯ Installation Guide
# Clone repository
git clone https://github.com/yagami1997/realcarrier.git
cd realcarrier
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt# Clone repository
git clone https://github.com/yagami1997/realcarrier.git
cd realcarrier
# Create virtual environment
python -m venv venv
# Activate virtual environment (CMD)
venv\Scripts\activate.bat
# Or (PowerShell)
.\venv\Scripts\Activate.ps1
# Install dependencies
pip install -r requirements.txt# Clone repository
git clone https://github.com/yagami1997/realcarrier.git
cd realcarrier
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate
# Install dependencies
pip install -r requirements.txtπ‘ Usage Guide
After activating the virtual environment, run the main program:
python main.py- Select "1. π API Key Management" from the main menu
- Choose the API provider you want to configure (Telnyx or Twilio)
- Enter the corresponding API key as prompted
- The key will be securely stored in the local configuration file
- Select "2. π Query Single Phone" from the main menu
- Enter a 10-digit US phone number (e.g., 8772427372)
- The system will display detailed information about the number
- Select "3. π Batch Query CSV File" from the main menu
- Enter the path to the CSV file containing phone numbers
- Specify the path for the output results file
- The system will process all numbers in batch and generate a results file
- Select "4. πΎ Cache Management" from the main menu
- Choose a cache operation:
- Display cache statistics
- Clear all cache
- Set cache expiration time
The program supports both Chinese and English interfaces. You can select "6. π Language Settings" in the main menu to switch:
- Select 1 to switch to Chinese
- Select 2 to switch to English
π Advanced CLI Usage
In addition to the interactive interface, this project also provides a command-line tool (lnp) for advanced users:
# Configure API key
lnp config set-key
# Query a single number
lnp lookup +14155552671
# Batch query
lnp batch numbers.csv -o results.csv
# Manage cache
lnp cache clear
lnp cache infoCommand Line Output
ββββββββββββββββββββββββββββββββββ
β Phone Number: +14155552671 β
ββββββββββββββββββββββββββββββββββ€
β Carrier: T-Mobile USA, Inc. β
β Number Type: mobile β
β Ported: Yes β
β Original Carrier: AT&T Mobilityβ
ββββββββββββββββββββββββββββββββββ
CSV Output Example
| Phone Number | Carrier | Number Type | Ported | Original Carrier |
|---|---|---|---|---|
| +14155552671 | T-Mobile USA, Inc. | mobile | Yes | AT&T Mobility |
| +14155552672 | Verizon Wireless | mobile | No | - |
π¨βπ» Developer Resources
# Create virtual environment
python -m venv venv
# Activate environment
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txtpytest- This tool uses the Telnyx and Twilio APIs, which may incur API call fees
- Critical Requirements:
- Telnyx: Requires completed KYC and deposit
- Twilio: Requires identity verification and account funding
- Ensure your API account status is normal before use to avoid query failures
This project is released under the GNU General Public License v3.0 (GPL 3.0).




