Skip to main content

MAAC Go SMS — send Taiwan SMS in 3 lines from Python. NCC-compliant, NT$50 free trial.

Project description

maacgo-sms · Python SDK

Taiwan-first SMS API. Send SMS in 3 lines of Python.

pip install maacgo-sms

Quickstart

from maacgo_sms import Maacgo

sms = Maacgo("sk_live_...")

r = sms.send(
    to="+886912345678",
    body="【你的品牌】驗證碼 123456,5 分鐘內有效。",
)
print(r["id"], r["status"])

Context manager

with Maacgo("sk_live_...") as sms:
    sms.send(to="+886912345678", body="...")

Batch send

sms.broadcast(
    name="週年慶",
    body="【你的品牌】週年慶 5 折起!",
    recipients=["+886912345678", "+886987654321"],
)

Errors

from maacgo_sms import Maacgo, MaacgoError

try:
    sms.send(to="09XXX", body="【...】Hi")
except MaacgoError as e:
    if e.data.get("error") == "ncc_blocked":
        print("NCC compliance failed:", e.data.get("issues"))
    elif e.data.get("error") == "insufficient_balance":
        print("Please top up")

Webhooks (Django / Flask / FastAPI)

import hmac, hashlib, os
from fastapi import FastAPI, Request, HTTPException

app = FastAPI()
SECRET = os.environ["CRESCLAB_WEBHOOK_SECRET"]

@app.post("/webhooks/cresclab")
async def webhook(request: Request):
    body = await request.body()
    sig = request.headers.get("x-cresclab-signature", "")
    expected = hmac.new(SECRET.encode(), body, hashlib.sha256).hexdigest()
    if not hmac.compare_digest(sig, expected):
        raise HTTPException(401)

    payload = await request.json()
    if payload["event"] == "sms.delivered":
        mark_delivered(payload["data"]["id"])
    return {"received": True}

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

maacgo_sms-0.1.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

maacgo_sms-0.1.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file maacgo_sms-0.1.0.tar.gz.

File metadata

  • Download URL: maacgo_sms-0.1.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for maacgo_sms-0.1.0.tar.gz
Algorithm Hash digest
SHA256 50fe4a256b8a019f1431d5d3e764b930bbd6e0ffa12c7fb36c21bd0cb63e7f3a
MD5 4a6b15026fc87d5ec895399ef7925188
BLAKE2b-256 0218f25ecb6b28a13e5e0d0a14b85be4c5a9b8611354f5cf7c04d1d8748d6b9f

See more details on using hashes here.

File details

Details for the file maacgo_sms-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: maacgo_sms-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for maacgo_sms-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46c9b0dee2677f2d903bc88ee4668ed2810d78f6a2b31085e6707594cde76c87
MD5 3fe6402e6394ce928ccf1e60564957c2
BLAKE2b-256 7ed3893a48bc39b8c0bf8b27167429c956c4986098b8b70ed3ad0b0259a3a3c3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page