SmsAero API client
Project description
SmsAero API client
Installation (from PyPI):
pip install -U smsaero-api
Usage example:
Get credentials from account settings page: https://smsaero.ru/cabinet/settings/apikey/
from pprint import pprint
from smsaero import SmsAero, SmsAeroException
SMSAERO_EMAIL = 'your email'
SMSAERO_API_KEY = 'your api key'
def send_sms(phone: int, message: str) -> dict:
"""
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.
Returns:
dict: A dictionary containing the response from the SmsAero API.
"""
api = SmsAero(SMSAERO_EMAIL, SMSAERO_API_KEY)
return api.send_sms(phone, message)
if __name__ == '__main__':
try:
result = send_sms(79038805678, 'Hello, World!')
pprint(result)
except SmsAeroException as e:
print(f"An error occurred: {e}")
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 79038805678 --message 'Hello, World!'
Run on Docker:
docker pull 'smsaero/smsaero_python:latest'
docker run -it --rm 'smsaero/smsaero_python:latest' smsaero_send --email "your email" --api_key "your api key" --phone 79038805678 --message 'Hello, World!'
Compatibility:
- Currently version of library is compatible with Python 3.6+.
- Previous versions of Python supported by versions 2.2.0 and below.
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-3.0.0.tar.gz
(19.9 kB
view details)
Built Distribution
File details
Details for the file smsaero_api-3.0.0.tar.gz
.
File metadata
- Download URL: smsaero_api-3.0.0.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8cded91f47713cc07d6ed889ca4420cf23dcf101b07ca34cf923a3103e5e4137 |
|
MD5 | c0c299f4742774c23529495b3d982754 |
|
BLAKE2b-256 | e7646b9c25df8d867b8fab25295939d430ea43ddedc6f5872a8bf313731b8aaf |
File details
Details for the file smsaero_api-3.0.0-py2.py3-none-any.whl
.
File metadata
- Download URL: smsaero_api-3.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 913ce45997b0a76ba22351ac5c9c575f46c0a7fcfb3f3d1f6c8fa9101d36472f |
|
MD5 | c8629e51ac7b80fc8c45c36b17e5524e |
|
BLAKE2b-256 | 63928e670c347fb22e8d98e3042296f9c66526c1a036cf2d89ee51df0cad09f3 |