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.3.0.tar.gz (83.6 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.3.0-py3-none-win_amd64.whl (8.6 MB view details)

Uploaded Python 3Windows x86-64

fastmeow-0.3.0-py3-none-manylinux2014_x86_64.whl (8.4 MB view details)

Uploaded Python 3

fastmeow-0.3.0-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.3.0.tar.gz.

File metadata

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

File hashes

Hashes for fastmeow-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b3994fc0c9e2b16c46e06178c5d634a9b5c94854de5c54935f6bdc66fc51bb7f
MD5 6a63bf5ea99b47dcb730d859795a0c3a
BLAKE2b-256 b1a0f6b59e3d3a1cb68f2f2598c40a7a11f82bbcc0f5e6e0d6fc476cf8b29ce0

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastmeow-0.3.0.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.3.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: fastmeow-0.3.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 8.6 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.3.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 c2d6668d7cf728c3e58461f7474c784d23cd132ec44f962eb427959ffb4bb330
MD5 b3b7a66e93d8cdbcaeead7ba5d27882e
BLAKE2b-256 84f8480b4b817e998277e4e10114876733744ea2f6c5304d7c9dd2f95b08d3a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastmeow-0.3.0-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.3.0-py3-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastmeow-0.3.0-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fddd73718895733dad1d1c4419b0d58e19c382d1f3c226f7765a932baa714487
MD5 a21931f2669ef08a725c6a780c312fac
BLAKE2b-256 d01abdf19eb3ee2c6a664787161fd9fdf7d6b890ae5fc6beb10eb24fe4715a43

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastmeow-0.3.0-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.3.0-py3-none-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for fastmeow-0.3.0-py3-none-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 b52f8fd7aa2599bd1807327c32ba036e4a9921c284ce25f8d5d012635c6f12e5
MD5 1beac33eb08c9537c8b2eb7c7d1cad23
BLAKE2b-256 242e14c396f29316349ff3f6b31e76c900ebcba9c65d7440d2778806fab7b1c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastmeow-0.3.0-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