Skip to main content

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 by httpx
  • 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)

License

MIT © Smarthive Tech Solution

Metadata

Release files for smarthivesms 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smarthivesms 1.0.1
File Size Uploaded Provenance Actions
smarthivesms-1.0.1.tar.gz 20.4 kB Without provenance Details for smarthivesms-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for smarthivesms 1.0.1
File Interpreter ABI Platform Actions
smarthivesms-1.0.1-py3-none-any.whl Python 3 none any Details for smarthivesms-1.0.1-py3-none-any.whl

Total release size: 28.1 kB

Release files / smarthivesms-1.0.1.tar.gz

Download URL smarthivesms-1.0.1.tar.gz
Size 20.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9a90f4883fe78b9effb7e3db49601895f6c50ed510b3be8e371422edadebdb37
BLAKE2b-256 checksum
How to use checksums
f62a3b7ad24b1cf6f016f188fd000dd67ef4d292c984e183e60d6459c06c2caa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","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.1-py3-none-any.whl

Download URL smarthivesms-1.0.1-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf620b9a6a1fd4a300a244352d6b755b0f0e8f769ba47973ddd5254b05f20039
BLAKE2b-256 checksum
How to use checksums
02483bc586fd7d3c62541ca185bdb5cfdac93c898064b426882fac071844373f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","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.1

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.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page