pySMSGateway
pySMSGateway is an asynchronous Python microservice that interacts with a GSM modem using Gammu. It provides a REST API for sending and receiving SMS messages and retrieving real-time modem and network details such as IMEI, signal quality, and carrier name. Incoming SMS messages can optionally be forwarded to any external service via a configurable webhook.
🚀 Features
- 📤 Send SMS via REST API
- 📥 Receive and decode incoming SMS messages
- 📶 Query modem details (IMEI, model, firmware, signal, operator, etc.)
- 🔁 Poll modem periodically for new messages
- 🔧 Easily integrates with automation, IoT, or monitoring systems
⚙️ Configuration
Set the following environment variables to configure the gateway:
| Variable | Description | Default |
|---|---|---|
WEBHOOK_URL |
URL to forward incoming SMS as a JSON payload (optional) | http://localhost:8123/webhook/sms |
WEBHOOK_TOKEN |
Optional bearer token for secure webhook POSTs | — |
GSM_DEVICE |
Path to GSM modem serial port (e.g. /dev/ttyUSB0) |
/dev/ttyUSB0 |
GSM_CONNECTION |
Modem connection string (e.g. at19200, at115200) |
at115200 |
POLL_INTERVAL |
Interval (seconds) to poll modem for new messages | 10 |
📡 API Endpoints
POST /api/sms/send
Send an SMS message via modem.
Request:
{
"number": "+15551234567",
"text": "Hello from pySMSGateway!"
}
Response:
{ "status": "SMS sent" }
GET /api/sms/info
Retrieve modem metadata and network diagnostics.
Response:
{
"manufacturer": "Quectel",
"model": "EC25",
"firmware": "01.000.01.001",
"imei": "867322032XXXXX",
"signal_quality": { "SignalStrength": 21, "SignalPercent": 55 },
"network_info": {
"NetworkCode": "310260",
"NetworkName": "T-Mobile",
"LAC": "0001",
"CID": "0A2B"
}
}
🔁 Webhook Forwarding
When an incoming SMS is received, a POST request is sent to your WEBHOOK_URL containing:
{
"phone": "+15559876543",
"date": "2025-06-22 11:30:00",
"message": "Your gateway is working!"
}
The Authorization: Bearer WEBHOOK_TOKEN header is included if configured.
🐳 Running via Docker
docker build -t pysmsgateway .
docker run --rm -it \
-e GSM_DEVICE=/dev/ttyUSB0 \
-e GSM_CONNECTION=at115200 \
-e WEBHOOK_URL=https://your-service.example.com/sms \
-e WEBHOOK_TOKEN=your-secret-token \
--device=/dev/ttyUSB0 \
-p 3000:3000 \
pysmsgateway
🛠️ Development
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt # include aiohttp, python-gammu, etc.
python sms_gateway.py
📝 License
MIT License
🤝 Contributing
Bug reports, feature suggestions, and pull requests are welcome!
Metadata
Release files for py-smsgateway-async 0.1.2
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 |
|---|---|---|---|---|
| py_smsgateway_async-0.1.2.tar.gz | 5.6 kB | Without provenance | Details for py_smsgateway_async-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_smsgateway_async-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for py_smsgateway_async-0.1.2-py3-none-any.whl |
Total release size: 12.8 kB
Release files / py_smsgateway_async-0.1.2.tar.gz
| Download URL | py_smsgateway_async-0.1.2.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
92c897771dc17bfb96b24d6874166df229f018ede7e6fe6a002aa101b0de57c4
|
|
BLAKE2b-256 checksum How to use checksums |
663b57ac8cb537d08bbe94b493d75f7fb25668c5ba833f7bc99673512abdf811
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.13
|
Release files / py_smsgateway_async-0.1.2-py3-none-any.whl
| Download URL | py_smsgateway_async-0.1.2-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5aeb1e792d0fc5ac7611d77d78b90847909d433cccaf870d4392dba44dd25370
|
|
BLAKE2b-256 checksum How to use checksums |
4207df397262b546084b6fa43393bf54f37f22018751731d70e4849aacd090ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.13
|
Security for py-smsgateway-async 0.1.2
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.