This release is a pre-release and may not be stable for production use.
TextVerified Python Library
This library eases the use of the TextVerified REST API from Python and provides a comprehensive interface for phone number verification services. It has been designed for production use and includes robust error handling, type hints, and extensive documentation.
Installation
Download and install using
pip install textverified
If you're on an older version of python (<3.11), install tomli first:
pip install tomli
Features
- Complete API Coverage: All TextVerified endpoints are supported
- Type Hints: Full type annotation support for better IDE experience
- Error Handling: Comprehensive exception handling with specific error types
- Dual Usage Patterns: Support for both instance-based and static usage
- Pagination: Automatic handling of paginated results
- Production Ready: Robust error handling and retry mechanisms
Quickstart
Authentication
You'll need your TextVerified API credentials. You can get these from your TextVerified dashboard.
There are two ways to authenticate:
Method 1: Environment Variables (Recommended)
export TEXTVERIFIED_API_KEY="your_api_key"
export TEXTVERIFIED_API_USERNAME="your_username"
Then use the static API:
from textverified import account as tv_account
# Get account details
account_info = tv_account.me()
print("Username:", account_info.username)
print("Balance:", account_info.current_balance)
Method 2: Configure Client Directly
Set your credentials by calling textverified.configure():
import textverified
textverified.configure(
api_key="your_api_key",
api_username="your_username"
)
Then use the static API:
from textverified import account as tv_account
# Get account details
account_info = tv_account.me()
print("Username:", account_info.username)
print("Balance:", account_info.current_balance)
Method 3: Direct Instantiation
You can create an instance of the client, this also provides better type hinting.
from textverified import TextVerified
client = TextVerified(
api_key="your_api_key",
api_username="your_username"
)
# Get account details
account_info = client.account.me()
print("Username:", account_info.username)
print("Balance:", account_info.current_balance)
Documentation
See the documentation for full details, including:
- API Reference: Complete documentation of all classes and methods
- Quick Start Guide: Get up and running quickly
- Examples: Real-world usage examples and patterns
- Error Handling: Best practices for robust applications
Support and Resources
When working with the TextVerified API, please refer to the official documentation:
- TextVerified API Documentation - Main REST API reference
- TextVerified Dashboard - Manage your account and view usage
- TextVerified Support - Get help and contact support
For support, please open a ticket at TextVerified Support
Examples
Complete Verification Workflow
from textverified import TextVerified, NumberType, ReservationType, ReservationCapability
import time, datetime
# Initialize client
client = TextVerified(api_key="your_api_key", api_username="your_username")
# 1. List available services
services = client.services.list(
number_type=NumberType.MOBILE,
reservation_type=ReservationType.VERIFICATION
)
print(f"Found {len(services)} available services")
for service in services[:5]: # Show first 5
print(f" {service.service_name}")
# 2. Create a verification
verification = client.verifications.create(
service_name="yahoo",
capability=ReservationCapability.SMS
)
print(f"Verification created: {verification.id}")
print(f"Phone number: {verification.number}")
# 3. Do something that sends a message to your number
time.sleep(10)
# 4. Wait for an incoming verification
messages = client.sms.incoming(
verification,
timeout=300,
since=datetime.fromtimestamp(0)
)
for message in messages:
print(f"Received: {message.sms_content}")
Waking Lines
from textverified import reservations, wake_requests, sms, NumberType, ReservationCapability, RentalDuration
import datetime
# 1. Create a wakeable (non-always-on) rental
reservation = reservations.create(
service_name="allservices",
number_type=NumberType.MOBILE,
capability=ReservationCapability.SMS,
is_renewable=False,
always_on=False,
duration=RentalDuration.THIRTY_DAY,
allow_back_order_reservations=False,
).reservations[0]
rental = reservations.details(reservation)
print(f"Reserved number {rental.number} with id {rental.id}")
# 2. Start a wake request for the rental
print("Sending wake request and waiting for active window...")
wake_request = wake_requests.create(rental)
duration = wake_request.usage_window_end - wake_request.usage_window_start
print(
f"Number {rental.number} is active from {wake_request.usage_window_start}"
f" to {wake_request.usage_window_end} (duration: {duration})"
)
# 3. Wait for the wake request to complete
time_until_start = wake_request.usage_window_start - datetime.datetime.now(datetime.timezone.utc)
print(f"Waiting for the number to become active... ({time_until_start})")
wake_response = wake_requests.wait_for_wake_request(wake_request)
# 3. Poll for SMS messages on the awakened number
print(f"Polling SMS messages for number {rental.number}...")
messages = sms.incoming(rental, timeout=duration.total_seconds())
for msg in messages:
print(f"Received SMS from {msg.from_value}: {msg.sms_content}")
Error Handling
from textverified import verifications, TextVerifiedError
try:
verification = verifications.create(
service_name="invalid_service",
capability="SMS"
)
except TextVerifiedError as e:
print(f"TextVerified API Error: {e}")
# Handle specific TextVerified errors
except Exception as e:
print(f"Unexpected error: {e}")
# Handle other exceptions
Metadata
Release files for textverified 0.1.0a2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| textverified-0.1.0a2.tar.gz | 110.0 kB | Without provenance | Details for textverified-0.1.0a2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| textverified-0.1.0a2-py3-none-any.whl | Python 3 | none | any | Details for textverified-0.1.0a2-py3-none-any.whl |
Total release size: 150.7 kB
Release files / textverified-0.1.0a2.tar.gz
| Download URL | textverified-0.1.0a2.tar.gz |
|---|---|
| Size | 110.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd2e2c0ff5a8c97d06db0c0146828afe6628ead5b8c8c6fde4367bcb34e66480
|
|
BLAKE2b-256 checksum How to use checksums |
012a4549761d91153425b20340a0cb57c6b490482cbb5f6b84ffc7c3a2f3aa74
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / textverified-0.1.0a2-py3-none-any.whl
| Download URL | textverified-0.1.0a2-py3-none-any.whl |
|---|---|
| Size | 40.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cca071399934b503c81b5aa50d49647cb8374d6dde43e1a8eeeb87f31ae6bbed
|
|
BLAKE2b-256 checksum How to use checksums |
b6a0e29bb0b0925d91cbf06bc019df531196d4e39f62fa68b012a15a170281fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for textverified 0.1.0a2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.