You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test_integration.py # live API tests (skipped without credentials)
67
71
```
68
72
69
73
---
70
74
71
75
## Reporting Bugs
72
76
73
-
Open an issue at https://github.com/boxlinknet/kwtsms_python/issues with:
77
+
Open an issue at https://github.com/boxlinknet/kwtsms-python/issues with:
74
78
75
79
1. Python version and OS
76
80
2. Package version (`pip show kwtsms`)
@@ -90,8 +94,7 @@ Open an issue before writing code for new features. Describe:
90
94
2. What the API would look like (function signature, return value)
91
95
3. Whether it requires a new API endpoint
92
96
93
-
Features that add external dependencies will not be accepted. The package
94
-
is and will remain zero-dependency.
97
+
Features that add mandatory external dependencies will not be accepted. The core package is zero-dependency. Optional extras (e.g., `kwtsms[async]` for aiohttp) are acceptable if declared under `[project.optional-dependencies]` in `pyproject.toml`.
95
98
96
99
---
97
100
@@ -101,8 +104,10 @@ is and will remain zero-dependency.
101
104
102
105
```
103
106
src/kwtsms/
104
-
__init__.py # Public API: KwtSMS, clean_message, normalize_phone, validate_phone_input
105
-
_core.py # All client logic
107
+
__init__.py # Public API: KwtSMS, AsyncKwtSMS, clean_message, normalize_phone,
Send SMS with automatic ERR028 retry. ERR028 means "wait 15 seconds before resending to this number." This method sleeps 16 seconds and retries automatically, up to `max_retries` times (default 3, so up to 4 total calls).
347
+
348
+
```python
349
+
result = sms.send_with_retry("96598765432", "Your OTP is: 123456")
350
+
# if ERR028 occurs: waits 16s and retries, up to 3 times
351
+
```
352
+
353
+
Non-ERR028 errors are returned immediately without retry. Never raises.
354
+
355
+
---
356
+
357
+
### `parse_webhook(payload)` → `dict`
358
+
359
+
Parse a kwtSMS delivery receipt webhook payload. kwtSMS can POST delivery receipts to your server as JSON.
360
+
361
+
```python
362
+
from kwtsms import parse_webhook
363
+
364
+
# In your webhook endpoint (Flask/FastAPI/Django):
365
+
result = parse_webhook(request.json)
366
+
if result["ok"]:
367
+
print(result["msg_id"]) # matches the msg-id from send()
Async version of `KwtSMS` for use with `asyncio`. Requires the optional `aiohttp` dependency:
380
+
381
+
```bash
382
+
pip install kwtsms[async]
383
+
```
384
+
385
+
```python
386
+
from kwtsms import AsyncKwtSMS
387
+
388
+
sms = AsyncKwtSMS.from_env()
389
+
390
+
asyncdefsend_otp(phone: str, code: str):
391
+
ok, balance, error =await sms.verify()
392
+
result =await sms.send(phone, f"Your OTP is: {code}")
393
+
delivery =await sms.status(result["msg-id"])
394
+
return result
395
+
```
396
+
397
+
`AsyncKwtSMS` mirrors `KwtSMS` exactly: `verify()`, `balance()`, `send()`, `status()`, `from_env()`, `purchased` property. Maximum 200 numbers per `send()` call (no auto-batching in async mode). All methods return dicts and never raise.
398
+
399
+
---
400
+
327
401
## Utility functions
328
402
329
403
```python
330
-
from kwtsms import normalize_phone, validate_phone_input, clean_message
404
+
from kwtsms import normalize_phone, validate_phone_input, clean_message, parse_webhook
Every API error response includes an `action` field with guidance:
474
+
Every API error response includes an `action` field with guidance. `send()` never raises: network failures are returned as a dict with `code="NETWORK"`.
401
475
402
476
```python
403
-
try:
404
-
result = sms.send("96598765432", "Your OTP for MYAPP is: 123456")
405
-
exceptRuntimeErroras e:
406
-
# Network/HTTP failure: log and retry
407
-
print(f"Network error: {e}")
477
+
result = sms.send("96598765432", "Your OTP for MYAPP is: 123456")
Copy file name to clipboardExpand all lines: pyproject.toml
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
[project]
2
2
name = "kwtsms"
3
-
version = "0.7.28"
3
+
version = "0.7.29"
4
4
description = "Python client for kwtSMS, the Kuwait SMS gateway trusted by top businesses to deliver messages worldwide, with private Sender ID, free API testing, and non-expiring credits."
0 commit comments