Production-grade Python SDK for the AxeDz CPaaS API (SMS, Email, Wallet)
Project description
AxeDz Python SDK
Production-grade Python SDK for the AxeDz CPaaS platform. Send SMS and email, manage wallet balances, and inspect usage transactions with a clean, typed API inspired by Stripe and Twilio SDKs.
Features
- SMS and email sending
- Wallet balance and transaction history
- API key authentication via
x-api-keyheader - Automatic retries with exponential backoff (network and 5xx errors)
- Rich, typed exception hierarchy
- Standardized response envelope (
success,data,meta) - Optional async client via
httpx - Environment variable configuration
Installation
pip install axedz
For async support:
pip install axedz[async]
Authentication
All requests are authenticated with your AxeDz API key via the x-api-key header:
x-api-key: <API_KEY>
You can pass the key directly or via environment variable:
export AXEDZ_API_KEY="your_api_key"
export AXEDZ_BASE_URL="https://your-api.example.com/api" # optional
Quick Start
from axedz import AxeDz
client = AxeDz("API_KEY")
# Send SMS
client.sms.send("+213xxxxxxxx", "Hello")
# Send email
client.email.send(
"user@mail.com",
"Welcome",
text="Hello from AxeDz",
)
# Wallet balance
print(client.wallet.balance())
# Usage transactions
print(client.wallet.transactions(limit=20, offset=0))
Usage
Initialize the client
from axedz import AxeDz
client = AxeDz(
api_key="your_api_key",
base_url="http://localhost:3000/api", # default
timeout=10, # seconds
max_retries=2, # retry network/5xx failures
debug=False, # enable request logging
)
Or use environment variables:
client = AxeDz() # reads AXEDZ_API_KEY and AXEDZ_BASE_URL
Use as a context manager to ensure the HTTP session is closed:
with AxeDz("API_KEY") as client:
client.sms.send("+213555123456", "Hello")
SMS
response = client.sms.send(
to="+213555123456",
message="Your verification code is 123456",
)
print(response["success"]) # True
print(response["data"]) # {"id": "...", "status": "queued"}
print(response["meta"]) # {"status_code": 202, ...}
Optional provider override:
client.sms.send("+213555123456", "Hello", provider="twilio")
Send plain text:
client.email.send(
"user@example.com",
"Welcome to AxeDz",
text="Thanks for signing up!",
)
Send HTML:
client.email.send(
"user@example.com",
"Invoice",
html="<h1>Your invoice</h1><p>Thank you.</p>",
)
Wallet
Fetch balance:
balance = client.wallet.balance()
print(balance["data"]["balance"])
print(balance["data"]["currency"])
List usage transactions:
transactions = client.wallet.transactions(limit=20, offset=0)
for event in transactions["data"]["records"]:
print(event)
pagination = transactions["data"]["pagination"]
print(pagination["total"], pagination["hasMore"])
Response format
Every SDK method returns a normalized envelope:
{
"success": True,
"data": { ... }, # API payload
"meta": { ... }, # status code, headers, pagination, etc.
}
Raw HTTP responses are never exposed.
Error handling
The SDK raises typed exceptions with full context:
| Exception | When |
|---|---|
ValidationError |
Invalid input or 400/422 API responses |
AuthenticationError |
Missing/invalid API key (401/403) |
RateLimitError |
Rate limit exceeded (429) |
ServerError |
Server-side failures (5xx) |
NetworkError |
Timeouts and connectivity issues |
AxeDzError |
Base class for all SDK errors |
Example:
from axedz import AxeDz, AuthenticationError, ValidationError
client = AxeDz("API_KEY")
try:
client.sms.send("", "Hello")
except ValidationError as error:
print(error.message)
print(error.status_code)
print(error.response_body)
print(error.request)
except AuthenticationError as error:
print("Check your API key:", error.message)
Retries
The SDK automatically retries failed requests when:
- A network error occurs (timeout, connection failure)
- The API returns a 5xx server error
It does not retry validation, authentication, or rate-limit errors. Retries use exponential backoff (default: 2 attempts).
Async client (optional)
import asyncio
from axedz.async_client import AsyncAxeDz
async def main():
async with AsyncAxeDz("API_KEY") as client:
result = await client.sms.send("+213555123456", "Hello")
print(result)
asyncio.run(main())
Install async dependencies first:
pip install axedz[async]
Development
git clone https://github.com/axedz/axedz-python.git
cd axedz-python
pip install -e ".[dev]"
pytest
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file axedz-1.0.0.tar.gz.
File metadata
- Download URL: axedz-1.0.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
209a3818d5b5fdf18faf08de5203f77fa4d327c95bcffdbd4e80dcf4ae277d1f
|
|
| MD5 |
bc674c1cccf505aa19e5629556e0386d
|
|
| BLAKE2b-256 |
048f4cc66c01e0f269c6e13518152f988f480cdfb33cb8af97aaab69a1a74870
|
File details
Details for the file axedz-1.0.0-py3-none-any.whl.
File metadata
- Download URL: axedz-1.0.0-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e42a9f5d6a6da3a3238e9b8131347a5e024837dacd1f6b5910ebe57bf8687350
|
|
| MD5 |
01b97a1ab165fe941443871504693fdb
|
|
| BLAKE2b-256 |
bb3978c82e18d17f79eaf0bc2084881c889f5390810fa45a46e041b2986e1d9f
|