Skip to main content

Async WhatsApp Web (Multi-Device) protocol client in pure Python, inspired by Baileys.

Project description

pyaileys

CI PyPI Python Versions License Code style: ruff

Async WhatsApp Web (Multi-Device) protocol client in pure Python, inspired by Baileys.

What This Is

  • WebSocket protocol client (no browser automation)
  • QR pairing + multi-device session persistence (Baileys-like auth folder)
  • asyncio API for receiving stanzas/events and sending messages
  • Minimal runtime deps: websockets, protobuf, cryptography

Status

This is an early-stage protocol client.

What works today:

  • MD session login + QR pairing
  • Basic 1:1 Signal E2E (pkmsg/msg) decrypt/encrypt
  • Basic text send (with multi-device fanout)
  • Media send (image, PTT voice note, documents, static location, contacts)
  • Media download/decrypt (image, audio/PTT, documents)
  • History Sync ingestion into an in-memory store

Limitations (Important)

  • Group E2E (skmsg) / Sender Keys: not implemented
  • Media support is partial: no video/stickers yet, and no automatic thumbnails/duration/waveform
  • App-state sync + rich chat/contact model: minimal (demo store)
  • API stability: no guarantees yet (pre-1.0)

Legal / Safety

This project is not affiliated with WhatsApp/Meta. Using unofficial clients may violate WhatsApp Terms of Service. You are responsible for compliance and for preventing abuse (spam/automation).

Installation

pip install pyaileys

Optional (pretty QR output in terminal + SVG QR file):

pip install "pyaileys[qrcode]"

Quickstart (Pair + Connect)

import asyncio

from pyaileys import WhatsAppClient


async def main() -> None:
    client, auth_state = await WhatsAppClient.from_auth_folder("./auth")

    async def on_update(update) -> None:
        # update is `pyaileys.socket.ConnectionUpdate`
        if update.qr:
            print("QR string:", update.qr)
        if update.connection:
            print("connection:", update.connection)

    async def on_creds_update(_creds) -> None:
        await auth_state.save_creds()

    client.on("connection.update", on_update)
    client.on("creds.update", on_creds_update)

    await client.connect()
    await auth_state.save_creds()

    # keep the process alive
    await asyncio.Event().wait()


asyncio.run(main())

Examples

Kitchen sink (interactive):

python examples/demo_app.py --auth ./auth --log-nodes

Simple CLI (decrypt + store + send text/media):

python examples/simple_cli.py --auth ./auth

QR-only helper (writes qr.svg into the auth dir if qrcode extra is installed):

python examples/login_qr.py

Development

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

ruff check .
ruff format .
mypy src/pyaileys
pytest -q

Releasing to PyPI (Trusted Publishing)

This repo includes a GitHub Actions workflow (.github/workflows/release.yml) that publishes to PyPI when you push a tag like v0.1.0.

  • Bump versions in pyproject.toml and src/pyaileys/__init__.py
  • Tag and push: git tag vX.Y.Z && git push --tags

Regenerating Generated Files

wabinary token tables are generated from a Baileys checkout:

git clone https://github.com/WhiskeySockets/Baileys.git /path/to/Baileys
python3 tools/gen_wabinary_constants.py --baileys /path/to/Baileys

proto/WAProto.proto is vendored from Baileys and patched to satisfy protoc:

python3 tools/patch_waproto_for_protoc.py
protoc -Iproto --python_out=src/pyaileys/proto proto/WAProto.proto

Credits

Contributing

See CONTRIBUTING.md, CODE_OF_CONDUCT.md, and SECURITY.md.

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

pyaileys-0.1.0.tar.gz (195.0 kB view details)

Uploaded Source

Built Distribution

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

pyaileys-0.1.0-py3-none-any.whl (158.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyaileys-0.1.0.tar.gz
  • Upload date:
  • Size: 195.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyaileys-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2edb7c8b2316286937d813eb20d2aab73724bee97f9612aa11420dedb735d096
MD5 91ab89d9278072cc3e58b2fde2032019
BLAKE2b-256 98dff023c1b0a099db717aa3746ccf7ced0e948cef7f111d8c1dc0599f6549b3

See more details on using hashes here.

Provenance

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

Publisher: release.yml on atiti/pyaileys

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

File details

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

File metadata

  • Download URL: pyaileys-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 158.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyaileys-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2f240d3ed623a607c095ceddbd4861462473c134cb21d2e9a6067bc28c323eec
MD5 16bdefb3a2e9cc022ddc3d883a9ac8f5
BLAKE2b-256 94a07de4f3e37a1dbb0b4ab3e0d0591320190102173837f38b0fc7ecec18c00d

See more details on using hashes here.

Provenance

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

Publisher: release.yml on atiti/pyaileys

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