smarthivesms 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- smarthivesms-1.0.0/LICENSE +21 -0
- smarthivesms-1.0.0/PKG-INFO +169 -0
- smarthivesms-1.0.0/README.md +137 -0
- smarthivesms-1.0.0/pyproject.toml +64 -0
- smarthivesms-1.0.0/src/smarthivesms/__init__.py +20 -0
- smarthivesms-1.0.0/src/smarthivesms/client.py +630 -0
- smarthivesms-1.0.0/src/smarthivesms/errors.py +50 -0
- smarthivesms-1.0.0/src/smarthivesms/py.typed +0 -0
- smarthivesms-1.0.0/tests/test_client.py +151 -0
- smarthivesms-1.0.0/uv.lock +389 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Smarthive Tech Solution
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: smarthivesms
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Official Python SDK for SmarthiveSMS — Nigerian & African SMS (TRX DND-bypass & MKT), WhatsApp OTP, Voice OTP, and Transactional Email API.
|
|
5
|
+
Project-URL: Homepage, https://smarthivesms.com
|
|
6
|
+
Project-URL: Documentation, https://docs.smarthivesms.com
|
|
7
|
+
Project-URL: Repository, https://github.com/smarthive-tech-solution/smarthivesms-sdks
|
|
8
|
+
Project-URL: Issues, https://github.com/smarthive-tech-solution/smarthivesms-sdks/issues
|
|
9
|
+
Author-email: Smarthive Tech Solution <support@smarthivesms.com>
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: africa,bulk-sms,cpaas,dnd-bypass,nigeria-sms,otp,smarthivesms,sms,transactional-email,voice-otp,whatsapp-otp
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Communications
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Requires-Dist: httpx>=0.25.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# smarthivesms (Official Python SDK)
|
|
34
|
+
|
|
35
|
+
Official Python SDK for [SmarthiveSMS](https://smarthivesms.com) — Nigerian & African omnichannel messaging API for **Transactional DND-bypass SMS (TRX)**, **Marketing Bulk SMS (MKT)**, **WhatsApp OTP**, **Automated Voice OTP**, and **Transactional Email**.
|
|
36
|
+
|
|
37
|
+
- Both **Synchronous (`SmarthiveSMS`)** and **Asynchronous (`AsyncSmarthiveSMS`)** clients powered by `httpx`
|
|
38
|
+
- Full type annotations (`py.typed`)
|
|
39
|
+
- Built-in support for the **free ₦50,000 auto-replenishing Developer Sandbox** (`SMTSBX_...` keys)
|
|
40
|
+
- Automatic retries on transient network / 5xx / 429 errors
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install smarthivesms
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Quick Start
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
import os
|
|
52
|
+
from smarthivesms import SmarthiveSMS
|
|
53
|
+
|
|
54
|
+
# Reads SMARTHIVE_API_KEY automatically, or pass explicitly.
|
|
55
|
+
# Use a Sandbox key (SMTSBX_...) for free ₦50,000 simulated testing.
|
|
56
|
+
client = SmarthiveSMS(api_key=os.getenv("SMARTHIVE_API_KEY"))
|
|
57
|
+
|
|
58
|
+
# Send a DND-bypass Transactional OTP SMS
|
|
59
|
+
res = client.sms.send(
|
|
60
|
+
sender="MyApp",
|
|
61
|
+
recipients="2348012345678",
|
|
62
|
+
msg="Your verification code is 492041.",
|
|
63
|
+
route="TRX",
|
|
64
|
+
)
|
|
65
|
+
print(res["message_id"])
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Async Usage (FastAPI / asyncio)
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from smarthivesms import AsyncSmarthiveSMS
|
|
72
|
+
|
|
73
|
+
async with AsyncSmarthiveSMS(api_key="SMTSBX_your_sandbox_key") as client:
|
|
74
|
+
res = await client.sms.send(
|
|
75
|
+
sender="MyApp",
|
|
76
|
+
recipients="2348012345678",
|
|
77
|
+
msg="Your login code is 849204.",
|
|
78
|
+
route="TRX",
|
|
79
|
+
)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Usage Examples
|
|
83
|
+
|
|
84
|
+
### Bulk SMS
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
client.sms.send_bulk(
|
|
88
|
+
sender="MyApp",
|
|
89
|
+
recipients=["2348012345678", "2348098765432"],
|
|
90
|
+
msg="Flash sale starts at noon!",
|
|
91
|
+
route="MKT",
|
|
92
|
+
)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Check SMS Delivery Status (DLR)
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
status = client.sms.status("msg_9041284")
|
|
99
|
+
print(status["status"]) # DELIVRD | UNDELIV | PENDING
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### WhatsApp OTP
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
client.whatsapp.send_otp(
|
|
106
|
+
recipient="2348012345678",
|
|
107
|
+
code="849204",
|
|
108
|
+
sender="MyApp",
|
|
109
|
+
)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Automated Voice OTP
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
call = client.voice.send_otp(phone="2348012345678", otp="8429")
|
|
116
|
+
status = client.voice.status(call["call_id"])
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Transactional Email
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
client.email.send(
|
|
123
|
+
to="user@example.com",
|
|
124
|
+
subject="Welcome to MyApp",
|
|
125
|
+
html="<h1>Welcome!</h1><p>Thanks for signing up.</p>",
|
|
126
|
+
from_email="no-reply@myapp.com",
|
|
127
|
+
from_name="MyApp",
|
|
128
|
+
)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Check Balance & Credits
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
bal = client.balance.get()
|
|
135
|
+
print(bal)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Error Handling
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from smarthivesms import (
|
|
142
|
+
SmarthiveAuthError,
|
|
143
|
+
SmarthiveValidationError,
|
|
144
|
+
SmarthiveRateLimitError,
|
|
145
|
+
SmarthiveError,
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
try:
|
|
149
|
+
client.sms.send(sender="MyApp", recipients="2348012345678", msg="Hi", route="TRX")
|
|
150
|
+
except SmarthiveAuthError as e:
|
|
151
|
+
print("Invalid API key:", e.message)
|
|
152
|
+
except SmarthiveValidationError as e:
|
|
153
|
+
print("Validation error:", e.message)
|
|
154
|
+
except SmarthiveRateLimitError as e:
|
|
155
|
+
print("Rate limited, retry after:", e.retry_after)
|
|
156
|
+
except SmarthiveError as e:
|
|
157
|
+
print("API error:", e.status_code, e.message)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Documentation & Links
|
|
161
|
+
|
|
162
|
+
- API Docs: https://docs.smarthivesms.com
|
|
163
|
+
- Dashboard & Free Sandbox: https://app.smarthivesms.com/signup
|
|
164
|
+
- OpenAPI 3.1 Spec: https://smarthivesms.com/openapi.json
|
|
165
|
+
- Official MCP Server for AI Agents: `npx -y smarthivesms-mcp`
|
|
166
|
+
|
|
167
|
+
## License
|
|
168
|
+
|
|
169
|
+
MIT © Smarthive Tech Solution
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# smarthivesms (Official Python SDK)
|
|
2
|
+
|
|
3
|
+
Official Python SDK for [SmarthiveSMS](https://smarthivesms.com) — Nigerian & African omnichannel messaging API for **Transactional DND-bypass SMS (TRX)**, **Marketing Bulk SMS (MKT)**, **WhatsApp OTP**, **Automated Voice OTP**, and **Transactional Email**.
|
|
4
|
+
|
|
5
|
+
- Both **Synchronous (`SmarthiveSMS`)** and **Asynchronous (`AsyncSmarthiveSMS`)** clients powered by `httpx`
|
|
6
|
+
- Full type annotations (`py.typed`)
|
|
7
|
+
- Built-in support for the **free ₦50,000 auto-replenishing Developer Sandbox** (`SMTSBX_...` keys)
|
|
8
|
+
- Automatic retries on transient network / 5xx / 429 errors
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install smarthivesms
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
import os
|
|
20
|
+
from smarthivesms import SmarthiveSMS
|
|
21
|
+
|
|
22
|
+
# Reads SMARTHIVE_API_KEY automatically, or pass explicitly.
|
|
23
|
+
# Use a Sandbox key (SMTSBX_...) for free ₦50,000 simulated testing.
|
|
24
|
+
client = SmarthiveSMS(api_key=os.getenv("SMARTHIVE_API_KEY"))
|
|
25
|
+
|
|
26
|
+
# Send a DND-bypass Transactional OTP SMS
|
|
27
|
+
res = client.sms.send(
|
|
28
|
+
sender="MyApp",
|
|
29
|
+
recipients="2348012345678",
|
|
30
|
+
msg="Your verification code is 492041.",
|
|
31
|
+
route="TRX",
|
|
32
|
+
)
|
|
33
|
+
print(res["message_id"])
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Async Usage (FastAPI / asyncio)
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from smarthivesms import AsyncSmarthiveSMS
|
|
40
|
+
|
|
41
|
+
async with AsyncSmarthiveSMS(api_key="SMTSBX_your_sandbox_key") as client:
|
|
42
|
+
res = await client.sms.send(
|
|
43
|
+
sender="MyApp",
|
|
44
|
+
recipients="2348012345678",
|
|
45
|
+
msg="Your login code is 849204.",
|
|
46
|
+
route="TRX",
|
|
47
|
+
)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Usage Examples
|
|
51
|
+
|
|
52
|
+
### Bulk SMS
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
client.sms.send_bulk(
|
|
56
|
+
sender="MyApp",
|
|
57
|
+
recipients=["2348012345678", "2348098765432"],
|
|
58
|
+
msg="Flash sale starts at noon!",
|
|
59
|
+
route="MKT",
|
|
60
|
+
)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Check SMS Delivery Status (DLR)
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
status = client.sms.status("msg_9041284")
|
|
67
|
+
print(status["status"]) # DELIVRD | UNDELIV | PENDING
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### WhatsApp OTP
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
client.whatsapp.send_otp(
|
|
74
|
+
recipient="2348012345678",
|
|
75
|
+
code="849204",
|
|
76
|
+
sender="MyApp",
|
|
77
|
+
)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Automated Voice OTP
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
call = client.voice.send_otp(phone="2348012345678", otp="8429")
|
|
84
|
+
status = client.voice.status(call["call_id"])
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Transactional Email
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
client.email.send(
|
|
91
|
+
to="user@example.com",
|
|
92
|
+
subject="Welcome to MyApp",
|
|
93
|
+
html="<h1>Welcome!</h1><p>Thanks for signing up.</p>",
|
|
94
|
+
from_email="no-reply@myapp.com",
|
|
95
|
+
from_name="MyApp",
|
|
96
|
+
)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Check Balance & Credits
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
bal = client.balance.get()
|
|
103
|
+
print(bal)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Error Handling
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from smarthivesms import (
|
|
110
|
+
SmarthiveAuthError,
|
|
111
|
+
SmarthiveValidationError,
|
|
112
|
+
SmarthiveRateLimitError,
|
|
113
|
+
SmarthiveError,
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
try:
|
|
117
|
+
client.sms.send(sender="MyApp", recipients="2348012345678", msg="Hi", route="TRX")
|
|
118
|
+
except SmarthiveAuthError as e:
|
|
119
|
+
print("Invalid API key:", e.message)
|
|
120
|
+
except SmarthiveValidationError as e:
|
|
121
|
+
print("Validation error:", e.message)
|
|
122
|
+
except SmarthiveRateLimitError as e:
|
|
123
|
+
print("Rate limited, retry after:", e.retry_after)
|
|
124
|
+
except SmarthiveError as e:
|
|
125
|
+
print("API error:", e.status_code, e.message)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Documentation & Links
|
|
129
|
+
|
|
130
|
+
- API Docs: https://docs.smarthivesms.com
|
|
131
|
+
- Dashboard & Free Sandbox: https://app.smarthivesms.com/signup
|
|
132
|
+
- OpenAPI 3.1 Spec: https://smarthivesms.com/openapi.json
|
|
133
|
+
- Official MCP Server for AI Agents: `npx -y smarthivesms-mcp`
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
MIT © Smarthive Tech Solution
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.24.0"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "smarthivesms"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Official Python SDK for SmarthiveSMS — Nigerian & African SMS (TRX DND-bypass & MKT), WhatsApp OTP, Voice OTP, and Transactional Email API."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Smarthive Tech Solution", email = "support@smarthivesms.com" }
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"smarthivesms",
|
|
17
|
+
"sms",
|
|
18
|
+
"nigeria-sms",
|
|
19
|
+
"bulk-sms",
|
|
20
|
+
"dnd-bypass",
|
|
21
|
+
"otp",
|
|
22
|
+
"whatsapp-otp",
|
|
23
|
+
"voice-otp",
|
|
24
|
+
"transactional-email",
|
|
25
|
+
"cpaas",
|
|
26
|
+
"africa"
|
|
27
|
+
]
|
|
28
|
+
classifiers = [
|
|
29
|
+
"Development Status :: 5 - Production/Stable",
|
|
30
|
+
"Intended Audience :: Developers",
|
|
31
|
+
"License :: OSI Approved :: MIT License",
|
|
32
|
+
"Operating System :: OS Independent",
|
|
33
|
+
"Programming Language :: Python :: 3",
|
|
34
|
+
"Programming Language :: Python :: 3.9",
|
|
35
|
+
"Programming Language :: Python :: 3.10",
|
|
36
|
+
"Programming Language :: Python :: 3.11",
|
|
37
|
+
"Programming Language :: Python :: 3.12",
|
|
38
|
+
"Programming Language :: Python :: 3.13",
|
|
39
|
+
"Topic :: Communications",
|
|
40
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
41
|
+
"Typing :: Typed"
|
|
42
|
+
]
|
|
43
|
+
dependencies = [
|
|
44
|
+
"httpx>=0.25.0"
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[project.optional-dependencies]
|
|
48
|
+
dev = [
|
|
49
|
+
"pytest>=8.0.0",
|
|
50
|
+
"pytest-asyncio>=0.23.0"
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
[project.urls]
|
|
54
|
+
Homepage = "https://smarthivesms.com"
|
|
55
|
+
Documentation = "https://docs.smarthivesms.com"
|
|
56
|
+
Repository = "https://github.com/smarthive-tech-solution/smarthivesms-sdks"
|
|
57
|
+
Issues = "https://github.com/smarthive-tech-solution/smarthivesms-sdks/issues"
|
|
58
|
+
|
|
59
|
+
[tool.hatch.build.targets.wheel]
|
|
60
|
+
packages = ["src/smarthivesms"]
|
|
61
|
+
|
|
62
|
+
[tool.pytest.ini_options]
|
|
63
|
+
asyncio_mode = "auto"
|
|
64
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from .client import AsyncSmarthiveSMS, SmarthiveSMS, SmsRoute
|
|
2
|
+
from .errors import (
|
|
3
|
+
SmarthiveAuthError,
|
|
4
|
+
SmarthiveError,
|
|
5
|
+
SmarthiveRateLimitError,
|
|
6
|
+
SmarthiveValidationError,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
__version__ = "1.0.0"
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
"__version__",
|
|
13
|
+
"SmarthiveSMS",
|
|
14
|
+
"AsyncSmarthiveSMS",
|
|
15
|
+
"SmsRoute",
|
|
16
|
+
"SmarthiveError",
|
|
17
|
+
"SmarthiveAuthError",
|
|
18
|
+
"SmarthiveValidationError",
|
|
19
|
+
"SmarthiveRateLimitError",
|
|
20
|
+
]
|