Python async library for sending SMS messages via SMS Aero API
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(70000000000, 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
Metadata
Release files for smsaero-api-async 3.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| smsaero_api_async-3.2.0.tar.gz | 21.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| smsaero_api_async-3.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.0 kB
Release files / smsaero_api_async-3.2.0.tar.gz
| Download URL | smsaero_api_async-3.2.0.tar.gz |
|---|---|
| Size | 21.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
294a8b4ce97e09402c95fedf3d1b25911dc976d98c3370d1ccf8ffc5c1e61014
|
|
BLAKE2b-256 checksum How to use checksums |
bc9b422bc52fed81832c114478d1608e4ffc0a765482f978fcf94d63e132d669
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.20
|
Release files / smsaero_api_async-3.2.0-py3-none-any.whl
| Download URL | smsaero_api_async-3.2.0-py3-none-any.whl |
|---|---|
| Size | 14.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
da798cbe16111bb8ab3a540c4fbb0bcd155df529f12a6231d5489414c687f663
|
|
BLAKE2b-256 checksum How to use checksums |
b651b30fdf1cfadb085899dd5cfbbcb4242273fcaa680f7aabf6ce3c2846c88e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.20
|