Python SDK for the NEXT SMS Tanzania - (
app.nextsms.co.tz) SMS API v2
# pynextsms πΉπΏ
**Python SDK for the NEXT SMS Tanzania SMS API v2**
---
## Table of Contents
- Documentation
- Requirements
- Features
- Installation
- Quick Start
- Authentication
- Usage Guide
- Send a Single SMS
- Broadcast to Multiple Recipients
- Send Different Messages (Bulk)
- Schedule an SMS
- Scheduled + Recurring SMS
- Flash SMS
- Context Manager
- Environment Variables
- Response Objects
- Error Handling
- Logging
- Running Locally
- Contributing
- Changelog
- License
---
## Documentation
- Official Next SMS API Documentation
## Requirements
- Next SMS Registration
- Python 3.8+
- requests >= 2.28
## Features
| Feature | Support |
|---|---|
| Send SMS to a single recipient | β
|
| Broadcast same message to multiple recipients | β
|
| Send different messages to different recipients | β
|
| Schedule SMS (one-time) | β
|
| Schedule SMS (recurring: hourly / daily / weekly / monthly) | β
|
| Flash (Class-0) SMS | β
|
| Auto-retry on transient 5xx errors | β
|
| Typed responses β no raw dict-wrangling | β
|
| Full type annotations + `py.typed` (mypy strict) | β
|
| Environment-variable credentials (12-factor ready) | β
|
| Zero dependencies beyond `requests` | β
|
| Python 3.8 β 3.12 | β
|
---
## Installation
pynextsms
```bash
pip install pynextsms
```
---
## Quick Start
```python
from pynextsms import SMSClient
client = SMSClient(token="your_bearer_token", sender_id="YOURBRAND")
resp = client.sms.send("255763930052", "Hello from PyNextSMS!")
print(resp)
# SMSResponse(β
sent, http=200, ref='a3f1c2d4')
```
---
## Authentication
Generate your **Bearer Token** from your Next SMS API Documentation.
### Option 1 β pass credentials directly *(quick scripts, notebooks)*
```python
client = SMSClient(token="your_bearer_token", sender_id="YOURBRAND")
```
### Option 2 β environment variables *(recommended for production)*
```bash
export PYNEXTSMS_TOKEN="your_bearer_token"
export PYNEXTSMS_SENDER_ID="YOURBRAND"
```
```python
client = SMSCl β¦