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)
  • Typing/recording indications (chatstate)
  • 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.1.tar.gz (195.7 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.1-py3-none-any.whl (159.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyaileys-0.1.1.tar.gz
  • Upload date:
  • Size: 195.7 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.1.tar.gz
Algorithm Hash digest
SHA256 c3cec76a98aad689d5cce3de89b3a495ce47c3eb73d76d06d935780e02b652ce
MD5 cc330eedd562f5b9a3cb4c47b3086669
BLAKE2b-256 076eff9174d858b3e2278a5d867715868159af95e50636cd1cb27bc8002ff632

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyaileys-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 159.1 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bbc263d2f9c3c88db82623488630e8f440086fe22755e05d2b608f6d8f0f8cec
MD5 ed8f4ec4607df88ecd5edaf035df6cd8
BLAKE2b-256 f94cb97c6fb8259ed8a4f7212d0fce12115aa57d3b93b5d0eda351da6f8682ff

See more details on using hashes here.

Provenance

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