Step-by-step examples covering everything from a first send to a production OTP system with CAPTCHA, rate limiting, and brute-force protection.
pip install kwtsms
# or with uv:
uv add kwtsmsRequires Python 3.8+, no external dependencies.
cp examples/.env.example .envKWTSMS_USERNAME=your_api_username # API user, NOT your phone number or website login
KWTSMS_PASSWORD=your_api_password
KWTSMS_SENDER_ID=KWT-SMS # Replace with a private Sender ID before production
KWTSMS_TEST_MODE=1 # Set to 0 when ready to deliver real messages
KWTSMS_LOG_FILE=kwtsms.log # Leave empty to disable request loggingCredentials: kwtsms.com: Account: API.
python examples/01-quickstart.pyExpected output: Connected! Balance: X credits
| # | File | What it covers | Docs |
|---|---|---|---|
| 01 | 01-quickstart.py |
Verify credentials, send your first SMS | docs |
| 02 | 02-otp.py |
Generate and send a one-time code (basic) | docs |
| 03 | 03-bulk.py |
Send to many numbers, auto-batching for >200 | docs |
| 04 | 04-validation.py |
Local phone validation and API routing check | docs |
| 05 | 05-error-handling.py |
Handle every error category with the right action | docs |
| 06 | 06-message-cleaning.py |
What clean_message() strips and why |
docs |
| 07 | 07-django.py |
Service class, view, management command | docs |
| 08 | 08-flask.py |
Flask blueprint, OTP endpoints, health check | docs |
| 09 | 09-fastapi.py |
FastAPI router, Pydantic models, Depends injection | docs |
| 10 | 10-otp-production.py |
Full production OTP: SQLite, CAPTCHA, rate limiting, brute-force | docs |
- Phone number formats: accepted, normalized, and rejected inputs
- Sender ID guide: Promotional vs Transactional, DND, registration
- Error codes ERR001–ERR033: descriptions and recommended actions
- Pre-launch checklist: credentials, security, content, anti-abuse
For a standalone cross-platform CLI, see kwtsms-cli.