A simple asynchronous Python API client for working with the Textverified REST API
Project description
Unofficial Textverified API client in Python
ℹ️ About the Project
This library is designed to access the TextVerified API using an asynchronous Python client.
🏎 The difference between the official and my code
🐢 The official Python client uses a slow http.client, and also stops the main stream (for example, the client.sms.incoming function)
🚀 My client uses aiohttp as a request handler, and also has support for create_task and gather processes without blocking the main flow.
🔐 This client also supports Bearer tokens and automatically generates them after they expire for secure access to the API (just like the official client, but faster)
💻 Installation
Library download is recommended for Python >= 3.9
pip install textverified_async
🛠 Usage
Current available methods:
- Account Info
- Bearer Token
- Service List
- Sales
- Billing Cycles
- Back order rental reservation
- List Reservations
- Verifications (Soon)
- New Rental / Verification
- Renewable Rentals
- NonRenewable Rentals
- SMS
- Calls and Voices
- Wake Requests
- Webhook
- Legacy
There is no documentation yet, but it is quite easy to use. You can also hold down CTRL on the client and view the available functions and models, or get the current mini-documentation by hovering over the function.
Import the library
from textverified_async.api import TextVerifiedApi
Then create an API class (it will automatically create a session and token)
api = TextVerifiedApi(“api-key”, “username”)
Next, you can safely use commands from the API using its class
For example:
info = await api.get_account_info()
Note: If you want to get the information you need right away, put the asynchronous function in parentheses
Example:
balance = (await api.get_account_info()).currentBalance
All responses from the API will have the same value as in Textverified REST.API
📋 Example
Here is an example of code for using the client (you will also see this code in the api.py class of the library):
from textverified_async.api import TextVerifiedApi
# Usage
async def main():
api = TextVerifiedApi(“api”, “mail”)
await api.generate_bearer ()
status = await api.check_token_status()
print(f“Token status: {status}”)
try:
# Get all rented numbers
all_rentals = await api.get_rentals()
print(f“Found {len(all_rentals)} rentals:”)
for rental in all_rentals:
print(f“- {rental.serviceName}: {rental.number} ({rental.state})”)
# Example of getting detailed information about a specific number
if all_rentals:
first_rental = all_rentals[0]
print(f“\nGetting details for rental: {first_rental.id}”)
rental_details = await api.get_rental_by_id(first_rental.id)
print(f“Detailed info for {rental_details.number}:”)
print(f“ Service: {rental_details.serviceName}”)
print(f“ State: {rental_details.state}”)
print(f“ Always on: {rental_details.alwaysOn}”)
print(f“ Can refund: {rental_details.refund.canRefund}”)
print(f“ Billing cycle ID: {rental_details.billingCycleId}”)
wake = await api.wake_up_reservation(first_rental.id)
print(f“\nWoke up {wake.usageWindowStart} | Woke down {wake.usageWindowEnd} with wake ID {wake.id}”)
except Exception as e:
print(f“Error: {e}”)
if __name__ == “__main__”:
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file textverified_async-0.0.2.tar.gz.
File metadata
- Download URL: textverified_async-0.0.2.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5cac4d8e875e725117bb31a821de5e7387e3cdad85447879416eec0114df010a
|
|
| MD5 |
7468bb46ad9a6e6687bc47f179c201a3
|
|
| BLAKE2b-256 |
bf5c69dcd110473a5afa44c62a12fe7b0a5c3a0ae0ab883188f531706d11031e
|
File details
Details for the file textverified_async-0.0.2-py3-none-any.whl.
File metadata
- Download URL: textverified_async-0.0.2-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
437009c61b06018db5d3f2fe8060c5324381d2c8ad036526ecc6ecd8f0c55ddc
|
|
| MD5 |
399d9e1e33b717fde5a9c6ce7ff3c3ff
|
|
| BLAKE2b-256 |
0faf65eeaea8ed562c975201983948e108a75f9a7a7f87ce85882566857ad81f
|