A client library for sending and managing SMS messages via the Android SMS Gateway API
Project description
Android SMS Gateway Python API Client
This is a Python client library for interfacing with the Android SMS Gateway API.
Requirements
Optional:
- pycryptodome - end-to-end encryption support
Installation
pip install android_sms_gateway
You can also install with preferred http client:
pip install android_sms_gateway[requests]
pip install android_sms_gateway[aiohttp]
pip install android_sms_gateway[httpx]
With encrypted messages support:
pip install android_sms_gateway[encryption]
Quickstart
Here's an example of using the client:
import asyncio
import os
from android_sms_gateway import client, domain, Encryptor
login = os.getenv("ANDROID_SMS_GATEWAY_LOGIN")
password = os.getenv("ANDROID_SMS_GATEWAY_PASSWORD")
# encryptor = Encryptor('passphrase') # for end-to-end encryption, see https://sms.capcom.me/privacy/encryption/
message = domain.Message(
"Your message text here.",
["+1234567890"],
)
def sync_client():
with client.APIClient(
login,
password,
# encryptor=encryptor,
) as c:
state = c.send(message)
print(state)
state = c.get_state(state.id)
print(state)
async def async_client():
async with client.AsyncAPIClient(
login,
password,
# encryptor=encryptor,
) as c:
state = await c.send(message)
print(state)
state = await c.get_state(state.id)
print(state)
print("Sync client")
sync_client()
print("\nAsync client")
asyncio.run(async_client())
Client
There are two client classes: APIClient
and AsyncAPIClient
. The
APIClient
is synchronous and the AsyncAPIClient
is asynchronous. Both
implement the same interface and can be used as context managers.
Methods
There are two methods:
send(message: domain.Message) -> domain.MessageState
: Send a new SMS message.get_state(_id: str) -> domain.MessageState
: Retrieve the state of a previously sent message by its ID.
HTTP Client
The API clients abstract away the HTTP client used to make requests. The library includes support for some popular HTTP clients and trys to discover them automatically:
Also you can implement your own HTTP client that conforms to the http.HttpClient
or ahttp.HttpClient
protocol.
Contributing
Contributions are welcome! Please submit a pull request or create an issue for anything you'd like to add or change.
License
This library is open-sourced software licensed under the Apache-2.0 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
Built Distribution
File details
Details for the file android-sms-gateway-1.1.0.tar.gz
.
File metadata
- Download URL: android-sms-gateway-1.1.0.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6d470ec08314f882d703199b2d8b1be99ac7a72c6562372f4b9ae94a530b658 |
|
MD5 | 1eade4b556d3c867edc0a2269e429da3 |
|
BLAKE2b-256 | a283b7292a766ef9a985297dbf3948cf0f339bf162876e5e53c33cf83791a77e |
File details
Details for the file android_sms_gateway-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: android_sms_gateway-1.1.0-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa122d7bebbb46bfcc8aca74692223ff00c7ef7b124cf854bb88ba915012949f |
|
MD5 | b64e0ea0a2c96d878ac8ac088ab6f721 |
|
BLAKE2b-256 | a33ea0bd268832ad8e25b922e370c6f0deea6c4f48c0188b45ac356e70324c8a |