Python library for sending SMS messages via SMS Aero API
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)
def send_telegram_code(phone: int, code: int, sign: str = None, text: str = None) -> dict:
"""
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).
sign (str, optional): The SMS sender name for fallback.
text (str, optional): The SMS message text for fallback.
Returns:
dict: A dictionary containing the response from the SmsAero API.
"""
api = SmsAero(SMSAERO_EMAIL, SMSAERO_API_KEY)
return api.send_telegram(phone, code, sign, text)
if __name__ == "__main__":
try:
# Send SMS
result = send_sms(70000000000, "Hello, World!")
pprint(result)
# Send Telegram code
telegram_result = send_telegram_code(70000000000, 1234, "SMS Aero", "Your code is 1234")
pprint(telegram_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 70000000000 --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 70000000000 --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
Metadata
Release files for smsaero-api 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 | Provenance | Actions |
|---|---|---|---|---|
| smsaero_api-3.2.0.tar.gz | 22.8 kB | Without provenance | Details for smsaero_api-3.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| smsaero_api-3.2.0-py3-none-any.whl | Python 3 | none | any | Details for smsaero_api-3.2.0-py3-none-any.whl |
Total release size: 37.8 kB
Release files / smsaero_api-3.2.0.tar.gz
| Download URL | smsaero_api-3.2.0.tar.gz |
|---|---|
| Size | 22.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
481283f0af22d7762b3e85344a19afcc6761800a4ecce01fa30764d39ec34cfe
|
|
BLAKE2b-256 checksum How to use checksums |
ef585b0c1a4b26bb82ccd1596f3759a2c65e8ec8779c2947d456c89c081f4861
|
| 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-3.2.0-py3-none-any.whl
| Download URL | smsaero_api-3.2.0-py3-none-any.whl |
|---|---|
| Size | 14.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fef30fc6ea7d08fbaa40187dc79759b548f05cddcf7cfb9b606cb46cc5407ea2
|
|
BLAKE2b-256 checksum How to use checksums |
0665af28e2f649f68b5ece55bc1786d97c4c34296e0c31061b2e9eb82b41392c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.20
|
Security for smsaero-api 3.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.