QwenPaw's fork of neonize with proto stubs regenerated against protoc 30.2 (gencode 6.30.2) so it cohabitates with protobuf 6.x ecosystems (grpcio-status, google-cloud-*, etc.). Upstream neonize ships stubs generated by protoc 32.1 which require protobuf runtime >= 7.34.1 and break those packages. Drop-in replacement: keeps the `neonize` import path unchanged.
Project description
๐ Neonize
WhatsApp Automation Made Simple for Python
A powerful Python library built on top of Whatsmeow - enabling seamless WhatsApp automation with enterprise-grade performance
Getting Started โข Features โข Examples โข Documentation โข Contributing
โจ What is Neonize?
Neonize is a cutting-edge Python library that transforms WhatsApp automation from complex to simple. Built on top of the robust Whatsmeow Go library, it delivers enterprise-grade performance with Python's ease of use and developer-friendly API.
๐ฏ Why Choose Neonize?
- ๐ฅ High Performance - Built with Go backend for maximum speed and efficiency
- ๐ Python Native - Seamless integration with your existing Python ecosystem
- ๐ก๏ธ Enterprise Ready - Production-tested with robust error handling and reliability
- โก Real-time - Handle messages, media, and events in real-time with async support
- ๐ง Easy Integration - Simple, intuitive API design for rapid development
- ๐ Well Documented - Comprehensive documentation with practical examples
๐ Features
Core Messaging
- โ Send and receive text messages
- โ Handle media files (images, videos, documents, audio)
- โ Group management and operations
- โ Real-time message events
- โ Message receipts and status tracking
Advanced Capabilities
- ๐ End-to-end encryption support
- ๐ฏ Contact and user information retrieval
- ๐ Call event handling
- ๐ Presence and typing indicators
- ๐ Polls and interactive messages
- ๐ซ Blocklist management
Developer Experience
- ๐ Event-driven architecture
- ๐ Built-in logging and debugging
- ๐๏ธ SQLite and PostgreSQL database support
- โก Both synchronous and asynchronous APIs
- ๐งช Comprehensive examples and documentation
๐ Sponsors
We are grateful to our sponsors who help make Neonize possible. Their support enables us to continue developing and maintaining this open-source project for the community.
๐ค Become a Sponsor
Your sponsorship helps us:
- โก Maintain and improve Neonize
- ๐ Fix bugs and add new features
- ๐ Create better documentation
- ๐ง Provide community support
- ๐ Keep the project free and open-source
Thank you to all our sponsors for believing in Neonize and supporting open-source development! ๐
๐ Getting Started
Prerequisites
- Python 3.8 or higher
- Go 1.19+ (for building from source)
Installation
pip install neonize
Quick Start
from neonize.client import NewClient
from neonize.events import MessageEv, ConnectedEv, event
# Initialize client
client = NewClient("your_bot_name")
@client.event(ConnectedEv)
def on_connected(client: NewClient, event: ConnectedEv):
print("๐ Bot connected successfully!")
@client.event(MessageEv)
def on_message(client: NewClient, event: MessageEv):
if event.message.conversation == "hi":
client.reply_message("Hello! ๐", event.message)
# Start the bot
client.connect()
event.wait() # Keep running
Async Version
import asyncio
from neonize.aioze.client import NewAClient
from neonize.aioze.events import MessageEv, ConnectedEv
client = NewAClient("async_bot")
@client.event(MessageEv)
async def on_message(client: NewAClient, event: MessageEv):
if event.Message.conversation == "ping":
await client.reply_message("pong! ๐", event)
async def main():
await client.connect()
await client.idle() # Keep receiving events
asyncio.run(main())
!!! important "Python 3.10+ Event Loop"
Neonize uses asyncio.run() as the standard entry point. The event loop is
automatically obtained via asyncio.get_running_loop() inside connect().
Do not use the deprecated asyncio.get_event_loop() or
loop.run_until_complete() โ these raise errors on Python 3.12+.
๐ก Examples
๐ฑ Basic Client Setup
from neonize.client import NewClient
from neonize.events import MessageEv, ConnectedEv, event
import logging
# Enable logging for debugging
logging.basicConfig(level=logging.INFO)
# Initialize the WhatsApp client
client = NewClient(
name="my-whatsapp-bot",
database="./neonize.db"
)
# Handle successful connection
@client.event(ConnectedEv)
def on_connected(client: NewClient, event: ConnectedEv):
print("๐ Successfully connected to WhatsApp!")
print(f"๐ฑ Device: {event.device}")
# Start the client
client.connect()
event.wait()
๐ฌ Sending Messages
from neonize.utils import build_jid
# Send simple text message
jid = build_jid("1234567890")
client.send_message(jid, text="Hello from Neonize! ๐")
# Send image with caption
with open("image.jpg", "rb") as f:
image_data = f.read()
image_msg = client.build_image_message(
image_data,
caption="Check out this amazing image! ๐ธ",
mime_type="image/jpeg"
)
client.send_message(jid, message=image_msg)
# Send document file
with open("document.pdf", "rb") as f:
doc_data = f.read()
doc_msg = client.build_document_message(
doc_data,
filename="document.pdf",
caption="Here is the document you requested",
mime_type="application/pdf"
)
client.send_message(jid, message=doc_msg)
๐ญ Message Event Handling
from neonize.events import MessageEv, ReceiptEv, PresenceEv
from datetime import datetime
# Handle incoming text messages
@client.event(MessageEv)
def on_message(client: NewClient, event: MessageEv):
message_text = event.message.conversation
sender_jid = event.info.message_source.sender
chat_jid = event.info.message_source.chat
print(f"๐จ Received from {sender_jid}: {message_text}")
# Auto-reply functionality
if message_text and message_text.lower() == "hello":
client.send_message(chat_jid, text="Hello there! ๐")
elif message_text and message_text.lower() == "help":
help_text = """
๐ค *Bot Commands:*
โข hello - Get a greeting
โข help - Show this help message
โข time - Get current time
โข joke - Get a random joke
"""
client.send_message(chat_jid, text=help_text)
elif message_text and message_text.lower() == "time":
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
client.send_message(chat_jid, text=f"๐ Current time: {current_time}")
# Handle message receipts (delivery status)
@client.event(ReceiptEv)
def on_receipt(client: NewClient, event: ReceiptEv):
print(f"๐ง Message {event.receipt.type}: {event.message_ids}")
# Handle typing indicators
@client.event(PresenceEv)
def on_presence(client: NewClient, event: PresenceEv):
chat = event.message_source.chat
participant = event.message_source.sender
print(f"๐ฌ {participant} is {event.presence} in {chat}")
๐ฅ Group Management
from neonize.utils import build_jid
# Create a new group
participants = [
build_jid("1234567890"),
build_jid("0987654321"),
]
group_info = client.create_group(
"My Awesome Group ๐",
participants
)
print(f"๐ Group created: {group_info.jid}")
# Get group information
group_info = client.get_group_info(group_jid)
print(f"๐ Group Name: {group_info.group_name}")
print(f"๐ Description: {group_info.group_desc}")
print(f"๐ฅ Participants: {len(group_info.participants)}")
# Add participants to group
client.update_group_participants(
group_jid,
[user_jid],
"add"
)
# Remove participants from group
client.update_group_participants(
group_jid,
[user_jid],
"remove"
)
# Update group name
client.update_group_name(
group_jid,
"New Group Name ๐ฏ"
)
# Update group description
client.update_group_description(
group_jid,
"This is our updated group description"
)
๐ Contact & Profile Management
# Get user profile information
profile = client.get_profile_picture(
user_jid,
full_resolution=True
)
print(f"๐ค Profile picture URL: {profile.url}")
print(f"๐ Profile ID: {profile.id}")
# Update your own status
client.set_presence("available")
print("โ
Status updated to available")
# Check if contacts are on WhatsApp
contacts = ["1234567890", "0987654321", "1122334455"]
registered_contacts = client.is_on_whatsapp(contacts)
for contact in registered_contacts:
if contact.is_in:
print(f"โ
{contact.jid} is on WhatsApp")
else:
print(f"โ {contact.query} is not on WhatsApp")
๐ Polls & Interactive Messages
from neonize.utils.enum import VoteType
# Create a poll
poll_msg = client.build_poll_vote_creation(
"What's your favorite programming language?",
["Python ๐", "Go ๐", "JavaScript ๐", "Rust ๐ฆ"],
VoteType.SINGLE_SELECT
)
client.send_message(chat_jid, message=poll_msg)
# Handle poll responses
@client.event(MessageEv)
def on_poll_vote(client: NewClient, event: MessageEv):
voter = event.info.message_source.sender
selected_options = event.message.poll_update_message.vote.selected_options
print(f"๐ {voter} voted for: {selected_options}")
๐๏ธ Project Structure
neonize/
โโโ examples/
โ โโโ async_basic.py
โ โโโ basic.py
โ โโโ multisession_async.py
โ โโโ multisession.py
โ โโโ paircode.py
โโโ goneonize/
โ โโโ build_python_proto.py
โ โโโ chat_settings_store.go
โ โโโ contact_store.go
โ โโโ go.mod
โ โโโ go.sum
โ โโโ main.go
โ โโโ defproto/
โโโ neonize/
โ โโโ __init__.py
โ โโโ client.py
โ โโโ events.py
โ โโโ types.py
โ โโโ aioze/ # Async client
โ โโโ proto/ # Protocol buffers
โ โโโ utils/ # Helper utilities
โโโ docs/
โ โโโ conf.py
โ โโโ index.rst
โ โโโ getstarted.rst
โโโ tools/ # Build and development tools
๐ Documentation
Core Classes
NewClient- Main synchronous WhatsApp clientNewAClient- Asynchronous WhatsApp client- Event System - Event handling and types
- Protocol Buffers - WhatsApp message definitions
- Utilities - Helper functions and enums
Event System
The event system in Neonize is built around decorators and type-safe events:
# Synchronous event handling
@client.event(MessageEv)
def on_message(client: NewClient, event: MessageEv):
handle_message(event)
@client.event(ReceiptEv)
def on_receipt(client: NewClient, event: ReceiptEv):
handle_receipt(event)
# Asynchronous event handling
@async_client.event(MessageEv)
async def on_message(client: NewAClient, event: MessageEv):
await handle_message_async(event)
Database Support
Neonize supports multiple database backends for storing session data:
# SQLite (default)
client = NewClient("bot_name", database="./app.db")
# PostgreSQL (recommended for production)
client = NewClient("bot_name", database="postgres://user:pass@localhost/dbname")
# In-memory (for testing)
client = NewClient("bot_name", database=":memory:")
Multi-Session Support
Handle multiple WhatsApp accounts simultaneously:
import asyncio
from neonize.aioze.client import ClientFactory, NewAClient
from neonize.aioze.events import MessageEv, ConnectedEv
client_factory = ClientFactory("multisession.db")
# Load existing sessions from database
for device in client_factory.get_all_devices():
client_factory.new_client(device.JID)
# Register shared event handlers
@client_factory.event(ConnectedEv)
async def on_connected(client: NewAClient, event: ConnectedEv):
print(f"โก Client connected")
@client_factory.event(MessageEv)
async def on_message(client: NewAClient, event: MessageEv):
text = event.Message.conversation
if text == "ping":
await client.reply_message("pong!", event)
async def main():
await client_factory.run() # connect() all clients
await client_factory.idle_all() # keep running
asyncio.run(main())
๐ค Contributing
We welcome contributions! Here's how you can help:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
Development Setup
# Clone the repository
git clone https://github.com/krypton-byte/neonize.git
cd neonize
# Install dependencies with Poetry
poetry install --with dev
# Or install with pip in development mode
pip install -e .
# Run the basic example
python examples/basic.py
# Run tests
python -m pytest
# Build documentation
cd docs && make html
Code Standards
- Follow PEP 8 for Python code style
- Use type hints for better code documentation
- Write comprehensive tests for new features
- Update documentation for API changes
- Ensure backward compatibility when possible
๐๏ธ Database Configuration
SQLite (Default)
Perfect for development and small-scale deployments:
client = NewClient("my_bot", database="./whatsapp.db")
PostgreSQL (Production Recommended)
For high-performance and scalable applications:
# Basic connection
client = NewClient("my_bot", database="postgres://username:password@localhost:5432/dbname")
# With SSL disabled
client = NewClient("my_bot", database="postgres://username:password@localhost:5432/dbname?sslmode=disable")
# With SSL required
client = NewClient("my_bot", database="postgres://username:password@localhost:5432/dbname?sslmode=require")
Connection Pool Settings
For production applications, configure connection pooling:
database_url = "postgres://user:pass@localhost:5432/neonize?pool_min_conns=5&pool_max_conns=20"
client = NewClient("production_bot", database=database_url)
๐ Quick Integration
With FastAPI
from contextlib import asynccontextmanager
from fastapi import FastAPI
from neonize.aioze.client import NewAClient
from neonize.aioze.events import MessageEv
from neonize.utils.jid import build_jid
whatsapp_client = NewAClient("fastapi_bot")
@whatsapp_client.event(MessageEv)
async def on_message(client: NewAClient, event: MessageEv):
if event.Message.conversation == "/api_status":
await client.reply_message("API is running! โ
", event)
@asynccontextmanager
async def lifespan(app: FastAPI):
# connect() automatically picks up the running event loop
await whatsapp_client.connect()
yield
await whatsapp_client.disconnect()
app = FastAPI(lifespan=lifespan)
@app.get("/send-message")
async def send_message(phone: str, message: str):
jid = build_jid(phone)
await whatsapp_client.send_message(jid, message)
return {"status": "sent"}
With Django
# apps.py
from django.apps import AppConfig
from neonize.client import NewClient
import threading
class WhatsAppConfig(AppConfig):
name = 'whatsapp_integration'
def ready(self):
self.whatsapp_client = NewClient("django_bot")
thread = threading.Thread(target=self.whatsapp_client.connect)
thread.daemon = True
thread.start()
With Flask
from flask import Flask, request, jsonify
from neonize.client import NewClient
import threading
app = Flask(__name__)
whatsapp_client = NewClient("flask_bot")
@app.route('/webhook', methods=['POST'])
def webhook():
data = request.json
phone = data.get('phone')
message = data.get('message')
if phone and message:
jid = build_jid(phone)
whatsapp_client.send_message(jid, text=message)
return jsonify({"status": "success"})
return jsonify({"status": "error"}), 400
if __name__ == '__main__':
# Start WhatsApp client in background
thread = threading.Thread(target=whatsapp_client.connect)
thread.daemon = True
thread.start()
app.run(debug=True)
๐ License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
๐ Acknowledgments
- Whatsmeow - The powerful Go library that powers Neonize
- Thundra - Companion library for easy bot creation
- Python Community - For the amazing ecosystem and support
- Contributors - All the developers who have contributed to this project
๐ Support
- ๐ง Issues: GitHub Issues
- ๐ฌ Discussions: GitHub Discussions
- ๐ Documentation: Full Documentation
- ๐ Related Projects: Thundra Framework
๐ Introducing Tryx
Looking for another powerful tool for WhatsApp automation? Check out Tryx โ a Rust-powered Python SDK designed for building WhatsApp automations with an async-first API, strong typing, and production-focused performance.
Why Tryx?
- Async-first architecture for event-driven bots
- Python-friendly API with namespace-based clients
- High-performance native core for protocol and transport workloads
- Typed interfaces for better editor support and safer integrations
Tryx combines the best of:
- Rust for protocol and runtime-heavy paths
- PyO3 for Python bindings
- Tokio for async orchestration
- Typed Python package distribution (.pyi + py.typed)
Note: This project is an independent developer SDK and is not affiliated with WhatsApp or Meta.
For more details, visit the Tryx repository.
๐ Related Projects
- Thundra - High-level bot framework built on Neonize
- Neonize Dart - Dart/Flutter wrapper for Neonize
- Whatsmeow - Go WhatsApp Web API library
- Tryx - Rust-powered Python SDK for WhatsApp automation
Made with โค๏ธ for the Python community
If this project helped you, please consider giving it a โญ on GitHub!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file neonize_qwenpaw-0.3.16.1.tar.gz.
File metadata
- Download URL: neonize_qwenpaw-0.3.16.1.tar.gz
- Upload date:
- Size: 6.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98423df2c18ded9659426d73b8cad9473e254094c11119c1dfd0cd8b3a9ab585
|
|
| MD5 |
be42698a962ecd39052b9e4ebbc67b3f
|
|
| BLAKE2b-256 |
39cfb66851579651b6cb1d75524e484a46c1716fd13778e2ec80e324556e98f7
|
File details
Details for the file neonize_qwenpaw-0.3.16.1-py310-none-manylinux2014_x86_64.whl.
File metadata
- Download URL: neonize_qwenpaw-0.3.16.1-py310-none-manylinux2014_x86_64.whl
- Upload date:
- Size: 6.9 MB
- Tags: Python 3.10
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68bdb8604c120bcb419d309c018db73a6854e6dd173878b1b14b0d52268925ae
|
|
| MD5 |
5d2c0bc26973bfae695d0a40f18787ed
|
|
| BLAKE2b-256 |
bc1de929031fc85f96730962c78f6a422665146b8de28292146dd9ccb74f3d42
|