Skip to main content

Async Python client for the WhatsApp multi-device protocol

Project description

pywhats

CI PyPI version Python versions License

Async Python client for the WhatsApp multi-device protocol.

Status: pre-alpha (0.2.0). Implements QR pairing, connect, send/receive text, disconnect, app-state sync, media (images, video, audio/voice notes, documents, stickers), reactions, quoted replies, edits/revoke, history sync, read receipts, presence, and group messaging.

⚠️ Use at your own risk. This is an independent, unofficial client and may violate WhatsApp's Terms of Service — using it can get an account banned; prefer a dedicated number. The bundled Signal crypto (pywhats.signal.experimental) is clean-room and unaudited — see SECURITY.md.

Install

pip install pywhats

Requires Python 3.11+.

Quick start

import asyncio
from pywhats import Client

async def main():
    client = Client()

    @client.on("qr")
    async def on_qr(qr: str):
        print("Scan this QR in WhatsApp → Linked Devices:")
        print(qr)

    @client.on("message")
    async def on_message(msg):
        print(f"{msg.sender}: {msg.text}")
        if msg.text == "ping":
            # Event handlers run on the receive loop, so don't `await` a
            # client call that waits on a server reply (send, receipts,
            # group info) directly here — it would block the loop that has
            # to read that reply. Dispatch it as a task instead.
            asyncio.create_task(client.send_text(msg.chat, "pong"))

    await client.connect()
    await client.wait_closed()

asyncio.run(main())

Note: event handlers are dispatched on the connection's receive loop. Keep them quick, and never await a Client call that waits on a server response (send_text, send_image, mark_read, get_group_info, send_group_text, …) from inside a handler — schedule it with asyncio.create_task(...) so the receive loop stays free to read the reply.

Roadmap

  • 0.1.0 — QR pair, connect, send/receive text, disconnect, app-state sync, media (send/receive images), history sync, read receipts, presence, group messaging
  • 0.2.0 — more media types (video/audio/document/sticker), message features (reactions/replies/edits/revoke)
  • 0.3.0+ — calls, newsletters, business

License

Apache License 2.0. See LICENSE.

This is an independent clean-room implementation of the WhatsApp multi-device protocol. It is not affiliated with or endorsed by WhatsApp LLC or Meta. Using unofficial clients may violate WhatsApp's Terms of Service and can get an account banned — use at your own risk, preferably with a dedicated number.

Acknowledgments

The protocol behavior implemented here was informed by public reverse-engineering writeups and by studying the documented behavior of the open-source whatsmeow (Go) and Baileys (TypeScript) projects. No code was copied from either; pywhats is an independent implementation.

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

pywhats-0.2.0.tar.gz (235.1 kB view details)

Uploaded Source

Built Distribution

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

pywhats-0.2.0-py3-none-any.whl (178.6 kB view details)

Uploaded Python 3

File details

Details for the file pywhats-0.2.0.tar.gz.

File metadata

  • Download URL: pywhats-0.2.0.tar.gz
  • Upload date:
  • Size: 235.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pywhats-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d5ae7dbdb024921b38aa47c5db79dfdeed1d2fe9a06a4551c7c91a79742b96bb
MD5 10e0fae89e6f63308b80eab322ffa445
BLAKE2b-256 243a20c1c69c32c2646692f3a2dda09ff1c242adb58b912b7c1940bacb81e3f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pywhats-0.2.0.tar.gz:

Publisher: release.yml on sanjay3290/pywhats

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

File details

Details for the file pywhats-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pywhats-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 178.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pywhats-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 274df72892ddd9b7ed2b7ac6b278b0957b277e0e0ee9e00c754803ed04b9d262
MD5 44d6ed8eed1a3aabdc88ca2bb29eb306
BLAKE2b-256 3cf44106b6b1cb9de2df57c9930d8e67d214de727b22cd14d04b834b15756d96

See more details on using hashes here.

Provenance

The following attestation bundles were made for pywhats-0.2.0-py3-none-any.whl:

Publisher: release.yml on sanjay3290/pywhats

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

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