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.1.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.1-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: waapi-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 ccd2285a1e9fe4de0924e3797fc7f868d18d9b1b67ec70d0cfdfb3fba3ac6c79
MD5 d6a941150b1922769fd5b3ceab72f18f
BLAKE2b-256 62d0a7808ede818437cf5517ee873dff88c5016336d590071ca08fb488abd2cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for waapi-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: waapi-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 19.7 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7c2a03fa5cc09f299e841fdfa20beab2e072acbf72817a886ef1b27fed695787
MD5 2a96cc2c9f00a6141eb8dad23ec240a8
BLAKE2b-256 365dfc9e4bd3a47c8b06ca31356cde9ee27932f04a805d783757f63b0d50141d

See more details on using hashes here.

Provenance

The following attestation bundles were made for waapi-0.1.1-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

This release

0.1.1 This release

2 files

0.1.0

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