Skip to main content

Pythonic, async-native WhatsApp automation SDK powered by an embedded whatsmeow Go sidecar.

Project description

FastMeow

English | 简体中文

Pythonic, async-native WhatsApp automation SDK powered by an embedded whatsmeow Go sidecar.

Why FastMeow

  • Zero-CGO Toolchain: Built with CGO_ENABLED=0, requiring no C compiler or Go installed on your machine.
  • Sidecar Architecture: Runs a specialized Go binary (whatsmeow) as a managed child process, communicating over high-speed gRPC.
  • Pythonic API: Modern async/await design inspired by FastStream and aiogram, featuring magic filters and mountable routers.
  • Performance: Capable of handling 100+ concurrent accounts on a single host.
  • Stability: Unlike direct CGO bindings, the sidecar process isolates the Go runtime from the Python interpreter.

Status

  • Alpha: Project is in early development.
  • Phase 1+2+3: Go sidecar, Python SDK, and the multi-platform release pipeline are shipped and verified.
  • Phase 4.1 ✅: Group management — 9 RPCs and 3 events.
  • Phase 4.2 ✅: Receipts and presence — 4 RPCs and 3 events, with automatic soft-event introspection.
  • CI Verified: Multi-platform wheels are tested via automated pipelines (mypy strict, ruff, 186 tests).
  • Distribution: Available on PyPI (latest: 0.2.1).

Installation

pip install fastmeow

Supported platforms: Linux (x86_64), macOS (arm64 12.0+), and Windows (x86_64). Requires Python 3.12+.

Quickstart

The following example implements a basic echo bot. On the first run, it will print a QR code in your terminal for pairing. Subsequent runs will reuse the session stored in the ./sessions/ directory.

from __future__ import annotations

import asyncio
import logging
from pathlib import Path

from fastmeow import (
    ConnectedEvent,
    Ctx,
    F,
    FastMeow,
    MessageEvent,
    Router,
)

logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(name)s: %(message)s")

router = Router(name="echo")


@router.connected()
async def announce_online(event: ConnectedEvent, ctx: Ctx) -> None:
    print(f"[{ctx.account_key}] online as {ctx.account_jid}")


@router.message(F.text == "ping")
async def pong(msg: MessageEvent, ctx: Ctx) -> None:
    await ctx.reply("pong")


@router.message(F.is_dm & ~F.from_me)
async def echo(msg: MessageEvent, ctx: Ctx) -> None:
    if not msg.text:
        return
    await ctx.reply(f"echo: {msg.text}")


async def main() -> None:
    session_dir = Path("./sessions").resolve()
    session_dir.mkdir(parents=True, exist_ok=True)
    async with FastMeow(session_dir=session_dir) as app:
        app.include_router(router)
        handle = app.add_account("demo", on_qr="terminal")
        print("waiting for pairing/connect...")
        await handle.ready(timeout=120)
        print(f"connected: {handle.account_key} -> {handle.jid}")
        try:
            await app.run_forever()
        except KeyboardInterrupt:
            print("interrupted; shutting down")


if __name__ == "__main__":
    asyncio.run(main())

Architecture

FastMeow uses a sidecar pattern to bridge the Go-based whatsmeow library with Python.

┌──────────────────────────────────────────────────────────────────┐
│ Your Python code                                                 │
│   router = Router(); @router.message(F.text == "ping") ...       │
└─────────────────────────────┬────────────────────────────────────┘
                              │ FastMeow SDK (async, Python 3.12+)
                              │   - Router / Filter / Ctx
                              │   - AccountHandle, multi-account
                              ▼
┌──────────────────────────────────────────────────────────────────┐
│ Embedded Go sidecar  (cmd/fastmeow-sidecar, CGO_ENABLED=0)       │
│   - one process per FastMeow app instance                        │
│   - localhost gRPC, auth-token handshake                         │
│   - wraps go.mau.fi/whatsmeow                                    │
│   - session storage in ./sessions/<account_key>/                 │
└─────────────────────────────┬────────────────────────────────────┘
                              │ WhatsApp Web protocol
                              ▼
                       WhatsApp servers

This approach eliminates the need for Docker or local Go toolchains. The sidecar binary is embedded within the platform-specific Python wheel and auto-discovered at runtime.

Concepts

FastMeow app

The main entry point, used as an async context manager to manage the lifecycle of the sidecar process and account connections.

Router

Used to organize handlers. Routers can be mounted into the main app or other routers, allowing for modular bot design.

F magic filter

A powerful, composable tool for event filtering. Supports logical operators like & (and), | (or), and ~ (not). Filters are evaluated in order; the first match wins.

Ctx

The context object passed to every handler. It carries account_key, account_jid, and helper methods like ctx.reply() for quick responses.

AccountHandle

Returned by app.add_account(). It provides methods to check connection status (.ready()) and retrieve account information like the JID.

Multi-account

FastMeow supports managing multiple WhatsApp accounts within a single app instance. Each account operates with its own isolated session directory.

QR pairing

Set on_qr="terminal" in add_account to print a QR code for initial pairing. Session data is persisted locally for automatic reconnection on subsequent starts.

Multi-account example

Manage multiple identities with a single router:

async with FastMeow(session_dir=session_dir) as app:
    app.include_router(router)
    
    # Alice and Bob share the same message handlers
    alice = app.add_account("alice", on_qr="terminal")
    bob = app.add_account("bob", on_qr="terminal")
    
    await asyncio.gather(alice.ready(), bob.ready())
    await app.run_forever()

Inside a handler, ctx.account_key will be "alice" or "bob" depending on which account received the event.

Public API at a glance

Top-level exports from fastmeow:

  • Core: FastMeow, AccountHandle
  • Routing: Router, SkipHandler, F, Filter, FilterResult
  • Context: Ctx, AccountClient
  • Events: Event, MessageEvent, ConnectedEvent, DisconnectedEvent, QREvent, PairSuccessEvent, LoggedOutEvent, UnknownEvent, GroupInfoEvent, JoinedGroupEvent, GroupParticipantUpdateEvent, ReceiptEvent, PresenceEvent, ChatPresenceEvent
  • Domain: Account, AccountState, SendResult, GroupInfo, GroupParticipant, GroupParticipantAction, GroupParticipantUpdateResult, ReceiptType, PresenceType, ChatPresenceState, ChatPresenceMedia
  • Exceptions: FastMeowError, ConfigurationError, AccountError, AccountAlreadyExistsError, AccountNotFoundError, MessagingError, MessageSendError, InvalidJIDError, ReplyNotAvailableError, PairingFailedError, PairingTimeoutError, SidecarError, SidecarStartupError, SidecarCrashedError, SidecarBinaryNotFoundError, TransportError, ManifestError, DispatchError, BackpressureError, HandlerSignatureError, GroupError, GroupNotFoundError, NotInGroupError, NotGroupAdminError, InviteLinkInvalidError, InviteLinkRevokedError

AccountClient (available as handle.client or ctx.client) exposes:

  • Messaging: send_text, send_reply, mark_read
  • Presence: send_presence, send_chat_presence, subscribe_presence
  • Groups (read): list_groups, get_group_info, preview_group_invite
  • Groups (write): create_group, set_group_name, set_group_topic, set_group_announce, set_group_locked, add_group_participants, remove_group_participants, promote_group_participants, demote_group_participants, get_group_invite_link, join_group, leave_group

Supported platforms

FastMeow provides pre-compiled sidecar binaries for:

  • Linux: x86_64 (manylinux2014)
  • macOS: arm64 (12.0+)
  • Windows: x86_64

Requirements: Python 3.12+.

Roadmap

  • Phase 3 ✅: Release pipeline and multi-platform wheel automation.
  • v0.1.0 ✅: Initial PyPI release.
  • Phase 4.1 ✅: Group management.
  • Phase 4.2 ✅: Receipts and presence (typing indicators, read receipts).
  • v0.2.1 ✅: Phase 4.1 + 4.2 published to PyPI.
  • Next:
    • Phase 4.3: Media messages (images, video, audio, documents, stickers).
  • Deferred:
    • Advanced session management UI.
    • Worker / Broker deployment topology.

Development

To set up a local development environment:

git clone https://github.com/jianjian2048/fastmeow
cd fastmeow
uv sync --frozen
uv run pytest
uv run ruff check .
uv run mypy src/fastmeow

License

Distributed under the MIT License. See LICENSE for details.

Acknowledgments

  • whatsmeow by tulir: The underlying Go library powering the sidecar.
  • neonize: Inspiration for wrapping whatsmeow in Python.

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

fastmeow-0.2.1.tar.gz (70.0 kB view details)

Uploaded Source

Built Distributions

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

fastmeow-0.2.1-py3-none-win_amd64.whl (8.5 MB view details)

Uploaded Python 3Windows x86-64

fastmeow-0.2.1-py3-none-manylinux2014_x86_64.whl (8.3 MB view details)

Uploaded Python 3

fastmeow-0.2.1-py3-none-macosx_12_0_arm64.whl (8.1 MB view details)

Uploaded Python 3macOS 12.0+ ARM64

File details

Details for the file fastmeow-0.2.1.tar.gz.

File metadata

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

File hashes

Hashes for fastmeow-0.2.1.tar.gz
Algorithm Hash digest
SHA256 73aabf64eb7063dc2dbf7000e91389ceaa37542e8ffb2fc774222d950cdee56d
MD5 24735938fb88d79cdfaf6cb7b216148d
BLAKE2b-256 0679daee7bea6a4ee9dd8049eac6fa325108b136c58a569b47e7b0192ce9c491

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastmeow-0.2.1.tar.gz:

Publisher: release.yml on jianjian2048/FastMeow

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

File details

Details for the file fastmeow-0.2.1-py3-none-win_amd64.whl.

File metadata

  • Download URL: fastmeow-0.2.1-py3-none-win_amd64.whl
  • Upload date:
  • Size: 8.5 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fastmeow-0.2.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 495665805737f5f6e6ba5fa6577fc5e4a402485512f6f3747fdd6e652d70c1e7
MD5 0d92de98f4e170dee43709b72e03204f
BLAKE2b-256 b493ecbe5d257639c7b7f9f1effc9b1c205c8550fb0f900b7796d09c0c9a27bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastmeow-0.2.1-py3-none-win_amd64.whl:

Publisher: release.yml on jianjian2048/FastMeow

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

File details

Details for the file fastmeow-0.2.1-py3-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastmeow-0.2.1-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 312513a23b0795d6df0368bffde34747e1b6473f22da29d183210694f33cb818
MD5 a0bc3c3f7de4fd5460e90bae356df94c
BLAKE2b-256 c4a62b97688f6bff28dc0312fdb189d90acfadc83cc6fd9e5142e46f0d10d1df

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastmeow-0.2.1-py3-none-manylinux2014_x86_64.whl:

Publisher: release.yml on jianjian2048/FastMeow

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

File details

Details for the file fastmeow-0.2.1-py3-none-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for fastmeow-0.2.1-py3-none-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 11a283cb77fdb0f17a4678d290780eb3651ab7edec73ee58e72a6f9f06cd3016
MD5 2bd6c5208ef92de276b1a411d5182611
BLAKE2b-256 a9a91982bb3a8317a53cc2962b15b9b602400115474a9d1fb3a258871a45718b

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastmeow-0.2.1-py3-none-macosx_12_0_arm64.whl:

Publisher: release.yml on jianjian2048/FastMeow

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