Skip to main content

Baileys-style WhatsApp Web socket for Python

Project description

wa-socket

wa-socket is a Python library that provides a WhatsApp Web socket interface using a Node.js backend powered by the Baileys library.

The goal is to let Python developers interact with WhatsApp Web without writing Node.js code.


Features

  • WhatsApp Web connection via QR code
  • Session persistence (scan once, reconnect automatically)
  • Python-first API
  • Node.js backend managed automatically
  • Suitable for scripts, services, and FastAPI apps

Requirements

  • Python 3.11.9
  • Node.js 22+

⚠️ Node.js 18 /20 are not supported
This is due to upstream dependency constraints in Baileys.

Download Node.js 22 from: https://nodejs.org/en/download

Verify installation:

node -v
npm -v


## How it works

`wa-socket` runs a lightweight Node.js process internally.

- Python controls everything
- Node.js is only used for WhatsApp Web (Baileys)
- Communication happens via stdin/stdout (JSON events)
- QR codes are rendered directly in the terminal

QR is rendered via Python stdout (PIPE mode). Terminal compatibility may vary by system.


## Quick Start

```python
from wa_socket import WhatsAppSocket

sock = WhatsAppSocket(session_id="default")

sock.on_message(lambda msg: print(msg))
sock.start()
sock.wait_for_connection()

sock.send_message("919XXXXXXXXX", "Hello from 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

wa_socket-0.1.7.tar.gz (28.4 kB view details)

Uploaded Source

Built Distribution

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

wa_socket-0.1.7-py3-none-any.whl (28.8 kB view details)

Uploaded Python 3

File details

Details for the file wa_socket-0.1.7.tar.gz.

File metadata

  • Download URL: wa_socket-0.1.7.tar.gz
  • Upload date:
  • Size: 28.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for wa_socket-0.1.7.tar.gz
Algorithm Hash digest
SHA256 8934276c8fd96f1fb10684226d8d5e813ccf75771ed045f6bbd2d4d5bdd4c9d9
MD5 cb45386c44141060e48c5bbee5fedbd5
BLAKE2b-256 cab9c1e0402b16fcd21781019fad1cdb9f272c200fbd184fa91c11c998d9c2a7

See more details on using hashes here.

File details

Details for the file wa_socket-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: wa_socket-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 28.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for wa_socket-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f3c2f8067f89df2785c5f6a5c355ee75d407146c326bc96413b67c7579fc14a5
MD5 5585f888d296fe722ad6066c3415307c
BLAKE2b-256 e70cf40f44ce355b4c621c9764e07598d9a4a632529da0a302817353b4b35256

See more details on using hashes here.

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