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(fToken status: {status})

    try:
        # Get all rented numbers
        all_rentals = await api.get_rentals()
        print(fFound {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(fDetailed 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(fError: {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_keynet-0.0.3.tar.gz (8.8 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_keynet-0.0.3-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file textverified_async_keynet-0.0.3.tar.gz.

File metadata

File hashes

Hashes for textverified_async_keynet-0.0.3.tar.gz
Algorithm Hash digest
SHA256 37cb45d6dce1e1b33406e9268564cb29520af6338ad78902c38e8f76e841bc7f
MD5 ffa658e18cbdbc52d9f57e1c63e4168d
BLAKE2b-256 e676d272a59a6c59c9d971755d2ad71511f0510c6e43d565dcfd2ffbe1a6351f

See more details on using hashes here.

File details

Details for the file textverified_async_keynet-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for textverified_async_keynet-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a49e4a60b00694d7e938846f3a5edd140fac4a3d7d691532a596014bb5032eba
MD5 e2e2deb7774b34e2621d9a39086aa588
BLAKE2b-256 75376ffdef1b1426c370ca4095cd215b8f64a67fe625595927b36413a58fef86

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