Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

textverified_async-0.0.1a0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

textverified_async-0.0.1a0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file textverified_async-0.0.1a0.tar.gz.

File metadata

  • Download URL: textverified_async-0.0.1a0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for textverified_async-0.0.1a0.tar.gz
Algorithm Hash digest
SHA256 1a18d99d38a53cb7fc35845dede012166962403138a26db80c837a9a90e9a9ae
MD5 784858845c5dbcce7702e240c27ff8a2
BLAKE2b-256 cada918c8e113b67bbb1aaa487a7de4a56f8b499f4713f3cfb2891e1e1da30b6

See more details on using hashes here.

File details

Details for the file textverified_async-0.0.1a0-py3-none-any.whl.

File metadata

File hashes

Hashes for textverified_async-0.0.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 3651bda4ad5379eeaaec1a54e031f66a253366b1488221930e68ab43b30259cf
MD5 790a65b46e16fbab3463f32146cb21a8
BLAKE2b-256 d7a529173446b18735a9fd96ae3fa306c9e28f566ff25466487d9e451f9cc722

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page