Skip to main content

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-key header
  • 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="https://api.axedz.com/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 SMS with callback metadata:

client.sms.send(
    to=["+213673442786"],
    message="test backend",
    provider="axedz",
    callback_url="https://url.com/callback",
    callback_data={"id": "22"},
)

Email

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>",
)

Send to multiple recipients and include callback metadata:

client.email.send(
    to=["user1@example.com", "user2@example.com"],
    subject="Welcome",
    body="<h1>Hello World</h1>",
    body_type="html",
    sender_name="AxeDz",
    callback_url="https://webhook.site/129b1309-5626-4a61-ac52-60f73fe4aa6b",
    callback_data={"user_id": 123},
)

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.

from axedz import AxeDz

client = AxeDz("")

client.sms.send( to=["+213673442786"], message="test backend", provider="axedz", callback_url="https://url.com/callback", callback_data={"id": "22"}, )

client.email.send( to=["senpaimato5@gmail.com", "mansouritaha675@gmail.com"], subject="Welcome from apibackend test", body="

Hello World

", body_type="html", sender_name="AxeDz", callback_url="https://webhook.site/129b1309-5626-4a61-ac52-60f73fe4aa6b", callback_data={"user_id": 123}, )

Metadata

Release files for axedz 3.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for axedz 3.0.0
File Size Uploaded Provenance Actions
axedz-3.0.0.tar.gz 14.6 kB Without provenance Details for axedz-3.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for axedz 3.0.0
File Interpreter ABI Platform Actions
axedz-3.0.0-py3-none-any.whl Python 3 none any Details for axedz-3.0.0-py3-none-any.whl

Total release size: 33.1 kB

Release files / axedz-3.0.0.tar.gz

Download URL axedz-3.0.0.tar.gz
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4340e90cbfdbe97516e2aad038e667fafe09fb70c14db28578ba5e7056d61e25
BLAKE2b-256 checksum
How to use checksums
4b6a339b420f0f5299c52078d9a956abfd374343ffad7d16bb6e121fd46c9dcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Release files / axedz-3.0.0-py3-none-any.whl

Download URL axedz-3.0.0-py3-none-any.whl
Size 18.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4c0835f51f67d2a37c2498e423a3e228c473abfe16dac39d7328c21b4e6ffaf9
BLAKE2b-256 checksum
How to use checksums
8f42fa238b07a923ccde6700223c6839ab06d6cfee68df66e9a43be7a3d7a32a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Security for axedz 3.0.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page