Skip to main content

wacent (Python)

Official Python SDK for the Wacent API. Standard library only, Python 3.9+.

pip install wacent

Send a message

import os
from wacent import Wacent, WacentError

client = Wacent(os.environ["WACENT_API_KEY"])

res = client.messages.send(
    whatsapp_account_id=device_id,   # connected number id, from client.devices.list()
    phone_number="+628123456789",    # E.164 with "+", or a group JID "...@g.us"
    content="Hello from Wacent",
)
# Sending is asynchronous: the status arrives via webhooks or client.messages.get(res["message_id"])

Results are plain dicts with the API's field names.

Resources

messages (send, list, get, react, edit, delete) · devices (list, create, get, qr, update, disconnect, reconnect, delete, get_privacy, set_privacy) · campaigns (list, create, get, update, delete, start — also resumes, pause, add_recipients, list_recipients, check_numbers, analytics) · contacts (list, create, get, update, delete, import_, verify) · contact_lists (list, create, delete, list_members, add_members, remove_member, phones) · groups (list, get, participants) · webhooks (list, create, update, delete, logs, test).

Errors

Every failure raises WacentError with status, code (e.g. DEVICE_OFFLINE, VALIDATION_ERROR, INVALID_ID) and message; validation errors carry issues.

try:
    client.campaigns.start(campaign_id)
except WacentError as e:
    if e.code == "DEVICE_NOT_CONNECTED":
        ...

Webhooks

from wacent import parse_webhook

@app.post("/wacent")          # Flask
def wacent_webhook():
    event = parse_webhook(request.get_data(), request.headers.get("X-WACENT-Signature"), os.environ["WACENT_WEBHOOK_SECRET"])
    if event["event"] == "message.received":
        print(event["data"]["fromNumber"], event["data"]["content"])
    return "", 200

Wacent signs with HMAC-SHA256(key = hex(sha256(secret)), raw_body), header sha256=<hex>. parse_webhook raises ValueError on a bad signature.

Tests

python -m unittest discover -s tests

Metadata

Release files for wacent 0.1.0

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

Source distribution (sdist)

Source distribution for wacent 0.1.0
File Size Uploaded Provenance Actions
wacent-0.1.0.tar.gz 10.6 kB Without provenance Details for wacent-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 18.2 kB

Release files / wacent-0.1.0.tar.gz

Download URL wacent-0.1.0.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b693852b853d822491cdaf5a64a83e95b48e7980f032995c726fbc836d5f9128
BLAKE2b-256 checksum
How to use checksums
0977ba859a8b6681695d1d95855afa66f6fd761837ace42bbf20730ebc05e1c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release files / wacent-0.1.0-py3-none-any.whl

Download URL wacent-0.1.0-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dbb6d1f927f5a7fcc77fb654ed8bd015a160d328ca40204195b0663aac9821e6
BLAKE2b-256 checksum
How to use checksums
244488490336e5ab96a10c6fe77813cbe357dad7ff2a2ff6cee743d357a08a8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Security for wacent 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 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