Skip to Content
SDKsPythonOverview

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); httpx for async
  • Source: github.com/SendAfrica/Python-SDK

Install

pip install sendafrica

For 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

Last updated on