Skip to main content

A high-performance WhatsApp Web automation library for Python.

Project description

Astra Engine Logo

Astra Engine

High-performance WhatsApp Web Automation Library for Python

Python Version License Code style: ruff Documentation


Astra Engine is a Python library that lets you automate WhatsApp Web. It uses Playwright to run a real browser instance, which means it works exactly like a real user. No hidden APIs, no ban risks from modified protocols—just meaningful automation.

We built this because existing libraries were either too slow, too brittle, or abandoned. Astra is designed to be the tool we wanted to use ourselves: written from scratch, typed, documented, and reliable.

⚡ What makes it different?

  • It's a Real Browser: We don't try to reverse-engineer the encrypted WebSocket protocol. We drive the official WhatsApp Web client, so if it works in Chrome, it works in Astra.
  • Privacy Focused: The engine automatically strips telemetry and tracking metrics. Your bot looks just like a normal user to WhatsApp's servers.
  • Developer Friendly: Full type hints, proper documentation, and sensible error messages. You won't have to guess what methods do.
  • Stays Connected: The connection manager handles QR code refreshes, internet dropouts, and browser crashes without you needing to write retry loops.

🚀 Features

Feature Status Notes
Multi-Device Works with the latest MD (Multi-Device) beta and stable.
Messaging Send text, reply to messages, mention users, edit sent messages.
Media Send and receive Images, Videos, Audio, Documents, and Stickers.
Interaction Create Polls, react to messages with emojis, delete messages.
Groups Extensive admin controls: promote/demote, change settings, manage participants.
Privacy Detailed control over who sees your profile, status, and last seen.
Events Real-time event loop to listen for new messages, status updates, and more.
Phone Pairing Login using your phone number instead of scanning a QR code.

📦 Installation

You need Python 3.9 or newer.

# 1. Install Astra Engine
pip install astra-engine

# 2. Install the browser binaries (Chromium)
python -m playwright install chromium

🛠️ Quick Start

Option A: QR Code Login

Here is the shortest way to get a bot running. This will print a QR code in your terminal—scan it with WhatsApp on your phone.

import asyncio
from astra import Client, Filters

async def main():
 # session_id saves your login so you don't have to scan every time
 async with Client(session_id="my_bot") as client:

  # Respond to "!ping"
  @client.on_message(Filters.command("ping"))
  async def ping(msg):
   await msg.respond("Pong! 🚀")

  # React to any message containing "hello"
  @client.on_message(Filters.text_contains("hello"))
  async def greet(msg):
   await msg.react("👋")

  print("Bot is running... Press Ctrl+C to stop.")
  await client.run_forever()

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

Option B: Phone Number Pairing

If you can't scan a QR code, you can use phone number pairing. Astra will print an 8-character code that you enter on your phone.

from astra import Client

client = Client(session_id="pairing_bot", phone="919876543210")
client.run_forever_sync()

👉 Enter the code printed in the terminal into WhatsApp > Linked Devices > Link with phone number. 👉 Check out the examples folder for more scripts like Group Management, Media Sending, and Background Tasks.


🤝 Want to Contribute?

We'd love your help! Astra is an open project. Whether you want to fix a bug, add a new feature, or just improve the docs, here is how you can get started.

  1. Fork the repo on GitHub.
  2. Clone it to your machine.
  3. Set up your environment:
# Create a virtual environment
python -m venv .venv
source .venv/bin/activate # or .venv\Scripts\activate on Windows

# Install in editable mode with dev dependencies
pip install -e ".[dev]"
python -m playwright install chromium
  1. Make your changes.
  2. Run the checks to make sure everything is clean:
# format code
ruff check . --fix

# check types
mypy astra
  1. Submit a Pull Request! We'll review it and get it merged.

⚖️ Disclaimer

This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries or its affiliates. The official WhatsApp website can be found at https://www.whatsapp.com.

This software is for educational purposes only. Automating user accounts may violate WhatsApp's Terms of Service. Use it responsibly and at your own risk.


Built with ❤️ by Aman Kumar Pandey

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

astra_engine-0.0.2b9.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

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

astra_engine-0.0.2b9-py3-none-any.whl (137.4 kB view details)

Uploaded Python 3

File details

Details for the file astra_engine-0.0.2b9.tar.gz.

File metadata

  • Download URL: astra_engine-0.0.2b9.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for astra_engine-0.0.2b9.tar.gz
Algorithm Hash digest
SHA256 696f60e95c6d5d5405619f1d1c1c9e3b8cfe7ed09c401b23c756ac9aee317bfe
MD5 02e20958edaf9af695ce6a7adea5a7d1
BLAKE2b-256 fb78fdafd1b4b9edaf3c5bf74114b1adabba5045138443fcb0175d816f0cf3ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for astra_engine-0.0.2b9.tar.gz:

Publisher: release.yml on paman7647/Astra

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

File details

Details for the file astra_engine-0.0.2b9-py3-none-any.whl.

File metadata

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

File hashes

Hashes for astra_engine-0.0.2b9-py3-none-any.whl
Algorithm Hash digest
SHA256 834da58540e099e167be51ab68be3112fcfe38b0af2809297145bc343dd74c82
MD5 d3e8ab986d917f688386c639dae347d6
BLAKE2b-256 8c7d7a1e4cf18c7294d5d434ca4166158a8a54e351d7585abb0d8e275b701583

See more details on using hashes here.

Provenance

The following attestation bundles were made for astra_engine-0.0.2b9-py3-none-any.whl:

Publisher: release.yml on paman7647/Astra

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