📡 MagfaSMS Python Client
A simple and clean Python client for interacting with
the Magfa SMS HTTP API v2.
This library allows you to send SMS messages, check message statuses, retrieve inbound messages, and monitor your
account balance.
🚀 Features
- ✅ Send SMS messages to multiple recipients
- 🔄 Track the delivery status of sent messages
- 📥 Fetch inbound (received) messages
- 💰 Check your Magfa account balance
- 🧾 Error code mapping for human-readable error handling
- 🔒 Built-in authentication with domain-based credentials
📦 Installation
pip install magfa
🛠️ Usage
🔐 Initialization
from magfa_sms import MagfaSMS
client = MagfaSMS(
username="your_username",
password="your_password",
domain="your_domain",
sender="your_sender_number"
)
✉️ Send an SMS
response = client.send(
recipients=["09123456789"],
messages=["Hello from Magfa!"]
)
print(response.json())
📊 Check Balance
balance_response = client.balance()
print(balance_response.json())
📩 Get Inbound Messages
inbound = client.messages(count=50)
print(inbound.json())
📡 Get Message Status
status = client.statuses(mid="123456789")
print(status.json())
🧠 Error Code Mapping
error_text = MagfaSMS.get_error_message(18)
print(error_text) # Output: Invalid username or password.
🚧 Configuration
| config name | description | type | status |
|---|---|---|---|
| MAGFA_DEBUG | log all requests/responses in stdout | environment variable | Optional |
for enabling DEBUG mode you can directly pass debug option for magfa class or set an environment variable
called MAGFA_DEBUG with string value ("True", "False")
from magfa import Magfa
magfa_client = Magfa(..., debug=False)
📚 Resources
Star History
🧑💻 Author
Developed by Ali Sharify
Metadata
Release files for magfa 1.0.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 | |
|---|---|---|---|
| magfa-1.0.0.tar.gz | 21.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| magfa-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 43.7 kB
Release files / magfa-1.0.0.tar.gz
| Download URL | magfa-1.0.0.tar.gz |
|---|---|
| Size | 21.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
17f6c7d30a27065b29817e42086b2c8929618a556d2485a2b8da4779d792c01a
|
|
BLAKE2b-256 checksum How to use checksums |
5f090190d91f1ccdd2f14ebc163195be0e09f5f8762022a096264f6cbeda8c6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / magfa-1.0.0-py3-none-any.whl
| Download URL | magfa-1.0.0-py3-none-any.whl |
|---|---|
| Size | 22.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8bb09cc2035dc3d22bff677028570c2d09668778d5a5338186fdb937113f16d8
|
|
BLAKE2b-256 checksum How to use checksums |
f03dba242fe61bd6d8a2c70e7952903769413e9da85e44d7a1d3338ee7235a3d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|