Skip to main content

SMS Aero Async API client

Project description

Python async library for sending SMS messages via SMS Aero API

PyPI version Python Versions Downloads License

Installation (from PyPI):

pip install -U smsaero-api-async

Usage example:

Get credentials from account settings page: https://smsaero.ru/cabinet/settings/apikey/

import pprint
import asyncio
import smsaero


SMSAERO_EMAIL = 'your email'
SMSAERO_API_KEY = 'your api key'


async def send_sms(phone: int, message: str) -> None:
    """
    Sends an SMS message

    Parameters:
    phone (int): The phone number to which the SMS message will be sent.
    message (str): The content of the SMS message to be sent.
    """
    api = smsaero.SmsAero(SMSAERO_EMAIL, SMSAERO_API_KEY)
    try:
        result = await api.send_sms(phone, message)
        pprint.pprint(result)
    finally:
        await api.close_session()


async def send_telegram_code(phone: int, code: int) -> None:
    """
    Sends a Telegram code

    Parameters:
    phone (int): The phone number to which the Telegram code will be sent.
    code (int): The Telegram code (4 to 8 digits).
    """
    api = smsaero.SmsAero(SMSAERO_EMAIL, SMSAERO_API_KEY)
    try:
        result = await api.send_telegram(phone, code)
        pprint.pprint(result)
    finally:
        await api.close_session()


if __name__ == '__main__':
    asyncio.run(send_sms(70000000000, 'Hello, World!'))
    asyncio.run(send_telegram_code(79990000000, 1234))

Exceptions:

  • SmsAeroException - base exception class for all exceptions raised by the library.
  • SmsAeroConnectionException - exception raised when there is a connection error.
  • SmsAeroNoMoneyException - exception raised when there is not enough money in the account.

Command line usage:

SMSAERO_EMAIL="your email"
SMSAERO_API_KEY="your api key"

smsaero_send --email "$SMSAERO_EMAIL" --api_key "$SMSAERO_API_KEY" --phone 70000000000 --message 'Hello, World!'

Run on Docker:

docker pull 'smsaero/smsaero_python_async:latest'
docker run -it --rm 'smsaero/smsaero_python_async:latest' smsaero_send --email "your email" --api_key "your api key" --phone 70000000000 --message 'Hello, World!'

Compatibility:

  • Currently version of library is compatible with Python 3.7+.

License:

MIT License

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

smsaero_api_async-3.1.0.tar.gz (20.2 kB view details)

Uploaded Source

Built Distribution

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

smsaero_api_async-3.1.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file smsaero_api_async-3.1.0.tar.gz.

File metadata

  • Download URL: smsaero_api_async-3.1.0.tar.gz
  • Upload date:
  • Size: 20.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for smsaero_api_async-3.1.0.tar.gz
Algorithm Hash digest
SHA256 4f100be5187ae738e544e9168919cc02b8d4b0cd9469836898edbea2892cfdfa
MD5 d9fadefe68b929ade8e7e1dd5df0dca8
BLAKE2b-256 e01dfe9db1e4dc21fcacdc92c276b505f285120ca85097033eca02eb4fe10e9e

See more details on using hashes here.

File details

Details for the file smsaero_api_async-3.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for smsaero_api_async-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2750efa960bffe9f50b58c52c243a5e978d04579cf3c219e47b23550d375c36f
MD5 2f2a62d9ce7c8e4557ba7e72aa49cc21
BLAKE2b-256 6ca4953487ed2e1089e3c52978c300ffaaa62b1a227bad4c7d6bc61becfa4d75

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