SDK Overview
Official AfriRoute client libraries for six languages. Each SDK wraps the REST API — SMS, Voice, WhatsApp, Email, USSD, and Payments — with idiomatic types, automatic retries, and Bearer-token authentication so you can send your first message in minutes.
Supported Languages
| Language | Package | Install | Guide |
|---|---|---|---|
| Node.js | afriroute | npm install afriroute | JavaScript |
| Python | afriroute | pip install afriroute | Python |
| C# / .NET | AfriRoute | dotnet add package AfriRoute | C# |
| Go | afriroute-sdk/go | go get afriroute.ai/sdk-go | Go |
| PHP | afriroute/afriroute | composer require afriroute/afriroute | PHP |
| Java | ai.afriroute:afriroute | Maven / Gradle | Java |
Authentication
Every SDK is initialized with your API key, sent as a Bearer token on each request to https://api.afriroute.ai:
Authorization: Bearer $AFRIROUTE_API_KEY
Find your keys under Settings → API Keys in the dashboard. Use a sandbox key for testing and a production key for live traffic.
What the SDKs Cover
| Service | Description |
|---|---|
| SMS | Send and receive SMS across 54+ African countries |
| Voice | Programmable voice calls and TTS |
| WhatsApp Business messaging | |
| Transactional and marketing email | |
| USSD | Interactive USSD sessions |
| Payments | Mobile money and wallet notifications |
Common Configuration
All SDKs accept the same options — a custom base URL (e.g. the sandbox), request timeout, and a maximum retry count. Retries use exponential back-off and automatically handle 429 rate-limit responses.
| Option | Default | Purpose |
|---|---|---|
| Base URL | https://api.afriroute.ai/api/v1 | Point at sandbox or production |
| Timeout | 60 seconds | Per-request timeout |
| Max retries | 5 | Automatic retry on transient errors |
Sandbox base URL:
https://api.afriroute.ai
Choosing an SDK
- Node.js / Python — fastest path for scripts, serverless, and web backends.
- C# / Java — strongly typed request/response models for enterprise stacks (Spring Boot, .NET, Android).
- Go — context-aware, dependency-light client for high-throughput services.
- PHP — drop-in for Laravel and Symfony applications.
Quick Example
import Afriroute from "afriroute";
const client = new Afriroute("$AFRIROUTE_API_KEY");
await client.sms.send({
to: "+251900000000",
message: "Hello from AfriRoute",
senderId: "AfriRoute",
});
Error Handling
Across all SDKs, failed requests raise a typed error (or return an error/err value in Go) carrying a machine-readable code, a human-readable message, and the HTTP status. Common codes include INVALID_API_KEY, INVALID_PHONE_NUMBER, INSUFFICIENT_BALANCE, and RATE_LIMIT_EXCEEDED. See each language guide for idiomatic handling.
Related Resources
Last Updated: May 2026 · Need help? Contact Support →