Python SDK
The official Python client for the SendAfrica REST API. It provides SendAfrica (sync, requests-based) and AsyncSendAfrica (async, httpx-based) clients with typed dataclass models, full phone normalization, local SMS part analysis, and a thin CLI.
Feature overview
- Package:
sendafrica— Python 3.9+ - Dependencies:
requests(always);httpxfor async - Source:
github.com/SendAfrica/Python-SDK
Install
pip install sendafricaFor async support (FastAPI, asyncio workers):
pip install sendafrica[async]Quickstart
import os
from sendafrica import SendAfrica
client = SendAfrica(api_key=os.environ["SENDAFRICA_API_KEY"])
result = client.sms.send(
to="0712345678",
message="Your verification code is 4921.",
)
print(result.message_id, result.status, result.credits_used)Place the API key in SENDAFRICA_API_KEY or pass it directly to the constructor. Keep credentials server-side and out of version control.
Pages in this section
- Installation
- Authentication
- SMS — single, send-many, bulk, logs, analysis
- Credits
- Payments
- Rates
- Sender IDs
- Webhooks
- Errors
- Phone Numbers
- CLI
- Async Support
- Lessons
Last updated on