Async Python client for the WhatsApp multi-device protocol
Project description
pywhats
Async Python client for the WhatsApp multi-device protocol.
Status: pre-alpha (0.1.0) — the first public release. Implements QR pairing, connect, send/receive text, disconnect, app-state sync, media (send/receive images), 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
awaitaClientcall that waits on a server response (send_text,send_image,mark_read,get_group_info,send_group_text, …) from inside a handler — schedule it withasyncio.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), 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pywhats-0.1.0.tar.gz.
File metadata
- Download URL: pywhats-0.1.0.tar.gz
- Upload date:
- Size: 213.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c65a397db93e6dbe471cfc820fb2bbb7fc504ea58f496615b0bc134193c71abd
|
|
| MD5 |
26b6b6a490c1bc8b2ea1d8fc44925044
|
|
| BLAKE2b-256 |
c93967ab33810bcb9a321ec78ca90f847fbf3e16260dc1d18f4e5a77ba671bd1
|
Provenance
The following attestation bundles were made for pywhats-0.1.0.tar.gz:
Publisher:
release.yml on sanjay3290/pywhats
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pywhats-0.1.0.tar.gz -
Subject digest:
c65a397db93e6dbe471cfc820fb2bbb7fc504ea58f496615b0bc134193c71abd - Sigstore transparency entry: 2128731934
- Sigstore integration time:
-
Permalink:
sanjay3290/pywhats@325a22a361bb1bdb1baf628dea41569c1285aa02 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/sanjay3290
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@325a22a361bb1bdb1baf628dea41569c1285aa02 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pywhats-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pywhats-0.1.0-py3-none-any.whl
- Upload date:
- Size: 170.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bd33dbd64cff61121e138489218d9f87a42367f598ce95d70ce2b0268bf9d9e
|
|
| MD5 |
f37cc6a557f82ba746887ee6e3aadd27
|
|
| BLAKE2b-256 |
8f9bbd351cc5883246918b4aee8d2bc3d2d23476f1ea61acba5fef8e5b3ce714
|
Provenance
The following attestation bundles were made for pywhats-0.1.0-py3-none-any.whl:
Publisher:
release.yml on sanjay3290/pywhats
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pywhats-0.1.0-py3-none-any.whl -
Subject digest:
5bd33dbd64cff61121e138489218d9f87a42367f598ce95d70ce2b0268bf9d9e - Sigstore transparency entry: 2128732043
- Sigstore integration time:
-
Permalink:
sanjay3290/pywhats@325a22a361bb1bdb1baf628dea41569c1285aa02 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/sanjay3290
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@325a22a361bb1bdb1baf628dea41569c1285aa02 -
Trigger Event:
push
-
Statement type: