Overview
whatsloon wraps the WhatsApp Cloud API (graph.facebook.com) with composable mixins for every message type: text, image, video, audio, document, sticker, reaction, location, contacts, templates, interactive lists / reply buttons / CTA / flows, typing indicators, and read receipts.
- Sync via
requests, async viahttpx - Validated payload builders with WhatsApp API limits
{"success": bool, "data" | "error"}result shape +logging- Full test suite, typed package (
py.typed), docs on GitHub Pages
Installation
pip install whatsloon
Requires Python >=3.9.
Quickstart
New code should use the v3 client (
to=, typed models, retries, observability) — see the messages guide. Below is the frozen 2.x API (critical fixes only).
from whatsloon import WhatsAppCloudAPIClient
client = WhatsAppCloudAPIClient(
access_token="YOUR_API_KEY",
phone_number_id="phone_number_id",
recipient_country_code="91",
recipient_mobile_number="9876543210",
)
result = client.send_text_message("Hello, world!", preview_url=True)
print(result)
Async:
import asyncio
from whatsloon import WhatsAppCloudAPIClient
async def main():
client = WhatsAppCloudAPIClient(
access_token="YOUR_API_KEY",
phone_number_id="phone_number_id",
recipient_country_code="91",
recipient_mobile_number="9876543210",
)
print(await client.async_send_text_message("Hello async!"))
asyncio.run(main())
Custom client with only needed features:
from whatsloon import WhatsAppBaseClient, TextSender, ImageSender
class MyClient(WhatsAppBaseClient, TextSender, ImageSender):
pass
See docs/quickstart.md, docs/usage.md, and examples/ for more.
Full docs: https://maharanasarkar.github.io/whatsloon/
Features
- Text, image, video, audio, document, sticker
- Interactive: lists, reply buttons, CTA, flows
- Location + location request, contacts, address
- Templates with components, reactions, typing indicators, read receipts
- Sync + async for every sender
Development
git clone https://github.com/maharanasarkar/whatsloon.git
cd whatsloon
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pre-commit install
pytest
ruff check .
ruff format --check .
mypy whatsloon
python -m build
See CONTRIBUTING.md, CODE_OF_CONDUCT.md, SECURITY.md.
Testing
pip install -e ".[test]"
pytest
pytest --cov=whatsloon tests/
Changelog
See CHANGELOG.md. Releases are cut from tags v* via Trusted Publishing to PyPI.
License
MIT — see LICENSE.
Metadata
Release files for whatsloon 3.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| whatsloon-3.1.0.tar.gz | 133.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| whatsloon-3.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 294.1 kB
Release files / whatsloon-3.1.0.tar.gz
| Download URL | whatsloon-3.1.0.tar.gz |
|---|---|
| Size | 133.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fea996eb649b73850ce4d4da07bbfa2b591ec19ce5673f308a75f436b4e3d2be
|
|
BLAKE2b-256 checksum How to use checksums |
ab30a808e5f1ddbe06c3201cb06968437309fa7980e601af81b3b1e6982d3f22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 10, 2026.
Transparency logRelease files / whatsloon-3.1.0-py3-none-any.whl
| Download URL | whatsloon-3.1.0-py3-none-any.whl |
|---|---|
| Size | 160.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d96ae55635794eec8972f79ccda83d6341c9c31c7a3657445c4d866449b3e9dd
|
|
BLAKE2b-256 checksum How to use checksums |
05754cd6aa5d27261beb46a047551fe5f622f79533ca2e41ac24e852142e4ff9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 10, 2026.
Transparency log