Skip to main content

WaAPI Python SDK

Official Python client for the WaAPI REST API — send and receive WhatsApp messages, manage chats, groups and channels from Python.

PyPI Python License

pip install waapi

Quick start

from waapi import WaAPI

client = WaAPI(token="YOUR_API_TOKEN", instance_id=123)

client.send_message(
    chat_id="4915112345678@c.us",
    message="Deployment finished.",
)

Get a token at waapi.app/user/api-tokens and create an instance connected to your number.

The chat ID is the one thing to get right

Its suffix decides where the message lands, and a wrong suffix is accepted and delivers nothing:

Target Format
One person 4915112345678@c.us
Group 123456789-123456789@g.us
Channel 123456789@newsletter

Async

Same method names, awaited:

from waapi import AsyncWaAPI

async with AsyncWaAPI(token="YOUR_API_TOKEN", instance_id=123) as client:
    await client.send_message(chat_id="4915112345678@c.us", message="Hi")

Errors

A successful HTTP exchange is not proof the message was sent. The API answers 200 with {"status": "error"} when, for example, the instance is not connected — so the SDK raises on that too, rather than handing back a body that looks like success.

from waapi import WaAPI, FailedActionError, AuthenticationError, RateLimitError

try:
    client.send_message(chat_id="4915112345678@c.us", message="Hi")
except AuthenticationError:
    ...                      # token wrong, expired, or missing scopes
except RateLimitError as e:
    time.sleep(e.retry_after or 5)
except FailedActionError as e:
    ...                      # accepted but not carried out — e.response has the detail
Exception Raised on
AuthenticationError HTTP 401, 403
NotFoundError HTTP 404
ValidationError HTTP 422 — .errors holds the field errors
RateLimitError HTTP 429 — .retry_after in seconds when the API sends it
FailedActionError HTTP 400, and HTTP 200 with status: error
ServerError HTTP 5xx

All inherit from WaAPIError.

Coverage

All 122 client actions are wrapped, typed, and available on both clients:

client.create_group(group_name="Ops", group_participants=["4915112345678@c.us"])
client.send_media(chat_id="4915112345678@c.us", media_url="https://example.com/report.pdf")
client.get_contacts()

They are generated from the same OpenAPI specification the n8n node and the MCP tools come from, so they track the API instead of drifting behind it — see CONTRIBUTING.md.

An action added to the API since the last release is still reachable by name:

client.action("some-new-action", {"chatId": "4915112345678@c.us"})

Configuration

WaAPI(
    token="...",              # required
    instance_id=123,          # optional; per-call instance_id overrides it
    base_url="https://waapi.app/api/v1",
    timeout=30.0,
)

Passing instance_id to the client keeps single-instance code short. Any call can still override it, and a call with neither raises before a request is sent.

Development

python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest

The suite runs entirely against httpx.MockTransport — no network, no token, no connected account.

License

MIT. Not affiliated with, endorsed or sponsored by WhatsApp LLC or Meta. WhatsApp is a trademark of WhatsApp LLC.

Download files

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

Source Distribution

waapi-0.1.0.tar.gz (26.9 kB view details)

Uploaded Source

Built Distribution

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

waapi-0.1.0-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: waapi-0.1.0.tar.gz
  • Upload date:
  • Size: 26.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for waapi-0.1.0.tar.gz
Algorithm Hash digest
SHA256 483d7c2c04bfc4dbcfc0972ce2204388a0dc3e72972c07bf2a383582b7bef89f
MD5 efbb43d64e09bbb9fd696c47b8fe6ca0
BLAKE2b-256 2b30ad7818ec61e49c248feb67d2cb88a1d651127b816846ee518ca805ceb7eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for waapi-0.1.0.tar.gz:

Publisher: publish.yml on WaAPIapp/waapi-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: waapi-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for waapi-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eb9eceadfe522918ef4e6dc4fcb8f9a938c8d5cc634b771f06dcb8e11d866a2a
MD5 edbd2e3d1213688cfab8ce2d96722484
BLAKE2b-256 3685fe307e579b78b0c9416a9af43a9f4d9c32a71fb1e11529ad6073d018d1bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for waapi-0.1.0-py3-none-any.whl:

Publisher: publish.yml on WaAPIapp/waapi-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.1

2 files

This release

0.1.0 This release

2 files

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