smarthivesms (Official Python SDK)
Official Python SDK for SmarthiveSMS — Nigerian & African omnichannel messaging API for Transactional DND-bypass SMS (TRX), Marketing Bulk SMS (MKT), WhatsApp OTP, Automated Voice OTP, and Transactional Email.
- Both Synchronous (
SmarthiveSMS) and Asynchronous (AsyncSmarthiveSMS) clients powered byhttpx - Full type annotations (
py.typed) - Built-in support for the free ₦50,000 auto-replenishing Developer Sandbox (
SMTSBX_...keys) - Automatic retries on transient network / 5xx / 429 errors
Installation
pip install smarthivesms
Quick Start
import os
from smarthivesms import SmarthiveSMS
# Reads SMARTHIVE_API_KEY automatically, or pass explicitly.
# Use a Sandbox key (SMTSBX_...) for free ₦50,000 simulated testing.
client = SmarthiveSMS(api_key=os.getenv("SMARTHIVE_API_KEY"))
# Send a DND-bypass Transactional OTP SMS
res = client.sms.send(
sender="MyApp",
recipients="2348012345678",
msg="Your verification code is 492041.",
route="TRX",
)
print(res["message_id"])
Async Usage (FastAPI / asyncio)
from smarthivesms import AsyncSmarthiveSMS
async with AsyncSmarthiveSMS(api_key="SMTSBX_your_sandbox_key") as client:
res = await client.sms.send(
sender="MyApp",
recipients="2348012345678",
msg="Your login code is 849204.",
route="TRX",
)
Usage Examples
Bulk SMS
client.sms.send_bulk(
sender="MyApp",
recipients=["2348012345678", "2348098765432"],
msg="Flash sale starts at noon!",
route="MKT",
)
Check SMS Delivery Status (DLR)
status = client.sms.status("msg_9041284")
print(status["status"]) # DELIVRD | UNDELIV | PENDING
WhatsApp OTP
client.whatsapp.send_otp(
recipient="2348012345678",
code="849204",
sender="MyApp",
)
Automated Voice OTP
call = client.voice.send_otp(phone="2348012345678", otp="8429")
status = client.voice.status(call["call_id"])
Transactional Email
client.email.send(
to="user@example.com",
subject="Welcome to MyApp",
html="<h1>Welcome!</h1><p>Thanks for signing up.</p>",
from_email="no-reply@myapp.com",
from_name="MyApp",
)
Check Balance & Credits
bal = client.balance.get()
print(bal)
Error Handling
from smarthivesms import (
SmarthiveAuthError,
SmarthiveValidationError,
SmarthiveRateLimitError,
SmarthiveError,
)
try:
client.sms.send(sender="MyApp", recipients="2348012345678", msg="Hi", route="TRX")
except SmarthiveAuthError as e:
print("Invalid API key:", e.message)
except SmarthiveValidationError as e:
print("Validation error:", e.message)
except SmarthiveRateLimitError as e:
print("Rate limited, retry after:", e.retry_after)
except SmarthiveError as e:
print("API error:", e.status_code, e.message)
Documentation & Links
- API Docs: https://docs.smarthivesms.com
- Dashboard & Free Sandbox: https://app.smarthivesms.com/signup
- OpenAPI 3.1 Spec: https://smarthivesms.com/openapi.json
- Official MCP Server for AI Agents:
npx -y smarthivesms-mcp
License
MIT © Smarthive Tech Solution
Metadata
Release files for smarthivesms 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| smarthivesms-1.0.0.tar.gz | 20.3 kB | Without provenance | Details for smarthivesms-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| smarthivesms-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for smarthivesms-1.0.0-py3-none-any.whl |
Total release size: 28.0 kB
Release files / smarthivesms-1.0.0.tar.gz
| Download URL | smarthivesms-1.0.0.tar.gz |
|---|---|
| Size | 20.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8cd44baea3014e045c3e54794071c657dca59310547f98853984f757ccc0039b
|
|
BLAKE2b-256 checksum How to use checksums |
0767c961f71bafa6bae8275374a7cfc2d7b84d0deec3c055f433df35f0dcb497
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / smarthivesms-1.0.0-py3-none-any.whl
| Download URL | smarthivesms-1.0.0-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
508b9c4a07c36c790516594d6572829a7be0f2ecd75fcbe7f62df6b17570359e
|
|
BLAKE2b-256 checksum How to use checksums |
bc59fb9c638ef5da5e695ac8cc6fd68a55c5edba1ea309090ff7430117df226e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for smarthivesms 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.