# TextVerified Python Library
[](https://pypi.python.org/pypi/textverified/)
[](https://github.com/Westbold/PythonClient/issues)
[](https://textverified-python.readthedocs.io/en/latest/)
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)**
```bash
export TEXTVERIFIED_API_KEY="your_api_key"
export TEXTVERIFIED_API_USERNAME="your_username"
```
Then use the static API:
```python
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():
```python
import textverified
textverified.configure(
api_key="your_api_key",
api_username="your_username"
)
```
Then use the static API:
```python
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.
```python
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)
```
## Examples
### Complete Verification Workflow
```python
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
```python
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
```python
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
```
## Documentation
See the [documentation](https://textverified.readthedocs.io/) 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
## TextVerified API Reference Links
When working with the TextVerified API, please refer to the official documentation:
1. [TextVerified API Documentation](https://www.textverified.com/docs/api/v2) - Main REST API reference
2. [TextVerified Dashboard](https://www.textverified.com/app/api/configure) - Manage your account and view usage
3. [TextVerified Support](https://www.textverified.com/app/support) - Get help and contact support
## Credits
This library is developed and maintained by **Westbold LLC**.
Special thanks to:
* **TextVerified** for providing a reliable phone verification service and comprehensive API
* **Python Community** for the excellent tools and libraries that make this project possible
* **Our Users** for feedback and contributions that help improve the library
For support, please open a ticket at [TextVerified Support](https://www.textverified.com/app/support)
Raw data
{
"_id": null,
"home_page": "https://textverified.com",
"name": "textverified",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "Textverified, Verification, Web Scraping, API, webhook, python",
"author": "Textverified",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/18/10/ccd53602ca0fcf654b94bef765b6de246ce48a8314c833852c01ac8b58ca/textverified-0.1.0a1.tar.gz",
"platform": null,
"description": "# TextVerified Python Library\n\n[](https://pypi.python.org/pypi/textverified/)\n[](https://github.com/Westbold/PythonClient/issues)\n[](https://textverified-python.readthedocs.io/en/latest/)\n\nThis 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.\n\n\n## Installation\n\nDownload and install using \n\n```\npip install textverified\n```\n\nIf you're on an older version of python (`<3.11`), install `tomli` first:\n```\npip install tomli\n```\n\n## Features\n\n- **Complete API Coverage**: All TextVerified endpoints are supported\n- **Type Hints**: Full type annotation support for better IDE experience\n- **Error Handling**: Comprehensive exception handling with specific error types\n- **Dual Usage Patterns**: Support for both instance-based and static usage\n- **Pagination**: Automatic handling of paginated results\n- **Production Ready**: Robust error handling and retry mechanisms\n\n\n## Quickstart\n\n### Authentication\n\nYou'll need your TextVerified API credentials. You can get these from your TextVerified dashboard.\n\nThere are two ways to authenticate:\n\n**Method 1: Environment Variables (Recommended)**\n\n```bash\nexport TEXTVERIFIED_API_KEY=\"your_api_key\"\nexport TEXTVERIFIED_API_USERNAME=\"your_username\"\n```\n\nThen use the static API:\n\n```python\nfrom textverified import account as tv_account\n\n# Get account details\naccount_info = tv_account.me()\nprint(\"Username:\", account_info.username)\nprint(\"Balance:\", account_info.current_balance)\n```\n\n**Method 2: Configure Client Directly**\n\nSet your credentials by calling textverified.configure():\n\n```python\nimport textverified\n\ntextverified.configure(\n api_key=\"your_api_key\",\n api_username=\"your_username\"\n)\n```\n\nThen use the static API:\n\n```python\nfrom textverified import account as tv_account\n\n# Get account details\naccount_info = tv_account.me()\nprint(\"Username:\", account_info.username)\nprint(\"Balance:\", account_info.current_balance)\n```\n\n**Method 3: Direct Instantiation**\n\nYou can create an instance of the client,\nthis also provides better type hinting.\n\n```python\nfrom textverified import TextVerified\n\nclient = TextVerified(\n api_key=\"your_api_key\",\n api_username=\"your_username\"\n)\n\n# Get account details\naccount_info = client.account.me()\nprint(\"Username:\", account_info.username)\nprint(\"Balance:\", account_info.current_balance)\n```\n\n## Examples\n\n### Complete Verification Workflow\n\n```python\nfrom textverified import TextVerified, NumberType, ReservationType, ReservationCapability\nimport time, datetime\n\n# Initialize client\nclient = TextVerified(api_key=\"your_api_key\", api_username=\"your_username\")\n\n# 1. List available services\nservices = client.services.list(\n number_type=NumberType.MOBILE,\n reservation_type=ReservationType.VERIFICATION\n)\n\nprint(f\"Found {len(services)} available services\")\nfor service in services[:5]: # Show first 5\n print(f\" {service.service_name}\")\n\n# 2. Create a verification\nverification = client.verifications.create(\n service_name=\"yahoo\",\n capability=ReservationCapability.SMS\n)\n\nprint(f\"Verification created: {verification.id}\")\nprint(f\"Phone number: {verification.number}\")\n\n# 3. Do something that sends a message to your number\ntime.sleep(10)\n\n# 4. Wait for an incoming verification\nmessages = client.sms.incoming(\n verification,\n timeout=300,\n since=datetime.fromtimestamp(0)\n)\nfor message in messages:\n print(f\"Received: {message.sms_content}\")\n```\n\n### Waking Lines\n\n```python\nfrom textverified import reservations, wake_requests, sms, NumberType, ReservationCapability, RentalDuration\nimport datetime\n\n# 1. Create a wakeable (non-always-on) rental\nreservation = reservations.create(\n service_name=\"allservices\",\n number_type=NumberType.MOBILE,\n capability=ReservationCapability.SMS,\n is_renewable=False,\n always_on=False,\n duration=RentalDuration.THIRTY_DAY,\n allow_back_order_reservations=False,\n).reservations[0]\nrental = reservations.details(reservation)\nprint(f\"Reserved number {rental.number} with id {rental.id}\")\n\n# 2. Start a wake request for the rental\nprint(\"Sending wake request and waiting for active window...\")\nwake_request = wake_requests.create(rental)\nduration = wake_request.usage_window_end - wake_request.usage_window_start\nprint(\n f\"Number {rental.number} is active from {wake_request.usage_window_start}\"\n f\" to {wake_request.usage_window_end} (duration: {duration})\"\n)\n\n# 3. Wait for the wake request to complete\ntime_until_start = wake_request.usage_window_start - datetime.datetime.now(datetime.timezone.utc)\nprint(f\"Waiting for the number to become active... ({time_until_start})\")\nwake_response = wake_requests.wait_for_wake_request(wake_request)\n\n\n# 3. Poll for SMS messages on the awakened number\nprint(f\"Polling SMS messages for number {rental.number}...\")\nmessages = sms.incoming(rental, timeout=duration.total_seconds())\nfor msg in messages:\n print(f\"Received SMS from {msg.from_value}: {msg.sms_content}\")\n```\n\n### Error Handling\n\n```python\nfrom textverified import verifications, TextVerifiedError\n\ntry:\n verification = verifications.create(\n service_name=\"invalid_service\",\n capability=\"SMS\"\n )\nexcept TextVerifiedError as e:\n print(f\"TextVerified API Error: {e}\")\n # Handle specific TextVerified errors\nexcept Exception as e:\n print(f\"Unexpected error: {e}\")\n # Handle other exceptions\n```\n\n## Documentation\n\nSee the [documentation](https://textverified.readthedocs.io/) for full details, including:\n\n- **API Reference**: Complete documentation of all classes and methods \n- **Quick Start Guide**: Get up and running quickly\n- **Examples**: Real-world usage examples and patterns\n- **Error Handling**: Best practices for robust applications\n\n## TextVerified API Reference Links\n\nWhen working with the TextVerified API, please refer to the official documentation:\n\n1. [TextVerified API Documentation](https://www.textverified.com/docs/api/v2) - Main REST API reference\n2. [TextVerified Dashboard](https://www.textverified.com/app/api/configure) - Manage your account and view usage\n3. [TextVerified Support](https://www.textverified.com/app/support) - Get help and contact support\n\n## Credits\n\nThis library is developed and maintained by **Westbold LLC**.\n\nSpecial thanks to:\n\n* **TextVerified** for providing a reliable phone verification service and comprehensive API\n* **Python Community** for the excellent tools and libraries that make this project possible\n* **Our Users** for feedback and contributions that help improve the library\n\nFor support, please open a ticket at [TextVerified Support](https://www.textverified.com/app/support)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python wrapper for the TextVerified API",
"version": "0.1.0a1",
"project_urls": {
"Documentation": "https://textverified-python.readthedocs.io/en/latest/",
"Download": "https://pypi.org/project/textverified/#files",
"Homepage": "https://textverified.com",
"Issues": "https://github.com/Westbold/PythonClient/issues",
"Source": "https://github.com/Westbold/PythonClient"
},
"split_keywords": [
"textverified",
" verification",
" web scraping",
" api",
" webhook",
" python"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "185d5d8be53bf3f486dfdae24efd40a79e8563a6c3af9a74b7d17d929f45c223",
"md5": "a6af91a5ef6f4213190c8c4ef3a21816",
"sha256": "9e954bf5d777fc5307fa9718f708923e91c73f860658691226fb7f02ad39d7e2"
},
"downloads": -1,
"filename": "textverified-0.1.0a1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a6af91a5ef6f4213190c8c4ef3a21816",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 32926,
"upload_time": "2025-08-04T18:49:59",
"upload_time_iso_8601": "2025-08-04T18:49:59.784709Z",
"url": "https://files.pythonhosted.org/packages/18/5d/5d8be53bf3f486dfdae24efd40a79e8563a6c3af9a74b7d17d929f45c223/textverified-0.1.0a1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "1810ccd53602ca0fcf654b94bef765b6de246ce48a8314c833852c01ac8b58ca",
"md5": "6461456d456af6efb41f3dd3da1cac70",
"sha256": "50236dc421f91f1e31c4912b6e256155d398e00ad313340546438ab1e580ca96"
},
"downloads": -1,
"filename": "textverified-0.1.0a1.tar.gz",
"has_sig": false,
"md5_digest": "6461456d456af6efb41f3dd3da1cac70",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 73343,
"upload_time": "2025-08-04T18:50:01",
"upload_time_iso_8601": "2025-08-04T18:50:01.166426Z",
"url": "https://files.pythonhosted.org/packages/18/10/ccd53602ca0fcf654b94bef765b6de246ce48a8314c833852c01ac8b58ca/textverified-0.1.0a1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-04 18:50:01",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Westbold",
"github_project": "PythonClient",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "textverified"
}