Tweakio-SDK: WhatsApp automation Python library with anti-detection, async storage, and production-grade architecture
Project description
Tweakio-SDK
Production-Grade WhatsApp Web Automation for Python
Anti-detection browser automation built on Playwright + Camoufox.
Documentation ยท PyPI ยท Issues ยท Contributing
๐ด The Problem
WhatsApp automation is broken:
- Detection & Bans โ Standard Selenium/Playwright scripts are fingerprinted and banned within hours
- Fragile Scripts โ When WhatsApp updates its UI, your selectors break. You spend weeks patching instead of building
- No Production Patterns โ Most automation tools are throwaway scripts, not production software with proper architecture
- Platform Lock-In โ Want to add Telegram later? Start from scratch
The industry treats automation as disposable code. We don't.
๐ก The Solution
Tweakio-SDK is a WhatsApp automation framework built with production-grade patterns:
| Problem | Tweakio Solution |
|---|---|
| Detection | Camoufox + BrowserForge fingerprinting (indistinguishable from humans) |
| Fragile selectors | Interface-driven architecture โ when WhatsApp breaks, only src/WhatsApp/ needs updates |
| No persistence | Async SQLite storage with background queue workers |
| No typing | Type-safe dataclasses for Chat and Message objects |
Current: WhatsApp Web (v0.1.5)
Roadmap: Telegram (Q2 2026), Instagram (Q3 2026)
๐ฆ Installation
pip install tweakio-sdk
Requirements: Python 3.10+, Playwright browsers
# Install Playwright browsers (one-time)
playwright install chromium
โก Quick Start
Basic: Fetch Chats
import asyncio
from BrowserManager import BrowserManager
from src.WhatsApp.login import Login
from src.WhatsApp.chat_processor import ChatProcessor
from src.WhatsApp.web_ui_config import WebSelectorConfig
from Custom_logger import logger
async def main():
# 1. Launch anti-detect browser
browser = BrowserManager(headless=False)
page = await browser.getPage()
# 2. Initialize UI config and Login
ui_config = WebSelectorConfig(page=page, log=logger)
login = Login(page=page, UIConfig=ui_config, log=logger)
# 3. Login (scan QR code on first run)
await login.login(save_path="./session.json")
# 4. Fetch chats
chat_processor = ChatProcessor(page=page, UIConfig=ui_config, log=logger)
async for chat, name in chat_processor.Fetcher(MaxChat=5):
print(f"๐ Chat: {name}")
asyncio.run(main())
Advanced: Message Processing with Storage
import asyncio
from BrowserManager import BrowserManager
from src.WhatsApp.login import Login
from src.WhatsApp.chat_processor import ChatProcessor
from src.WhatsApp.message_processor import MessageProcessor
from src.WhatsApp.web_ui_config import WebSelectorConfig
from src.StorageDB.sqlite_db import SQLITE_DB
from Custom_logger import logger
async def main():
# Browser + Login setup (same as above)
browser = BrowserManager(headless=False)
page = await browser.getPage()
ui_config = WebSelectorConfig(page=page, log=logger)
login = Login(page=page, UIConfig=ui_config, log=logger)
await login.login(save_path="./session.json")
# Initialize async storage
queue = asyncio.Queue()
async with SQLITE_DB(queue=queue, log=logger, db_path="messages.db") as storage:
# Initialize processors
chat_processor = ChatProcessor(page=page, UIConfig=ui_config, log=logger)
msg_processor = MessageProcessor(
page=page,
UIConfig=ui_config,
chat_processor=chat_processor,
log=logger,
storage=storage # Messages auto-saved to SQLite
)
# Fetch and process messages
async for chat, name in chat_processor.Fetcher(MaxChat=3):
print(f"๐ Processing: {name}")
# Fetcher returns wrapped Message objects with deduplication
messages = await msg_processor.Fetcher(chat=chat, retry=3)
for msg in messages:
print(f" ๐ฌ {msg.data_type}: {msg.raw_data[:50]}...")
print(f" ID: {msg.message_id}")
print(f" Direction: {msg.direction}")
asyncio.run(main())
๐๏ธ Architecture
tweakio-sdk/
โโโ src/
โ โโโ BrowserManager/ # Anti-detect Playwright + Camoufox
โ โโโ WhatsApp/ # Platform-specific implementation
โ โ โโโ login.py # QR + Phone authentication
โ โ โโโ chat_processor.py
โ โ โโโ message_processor.py
โ โ โโโ web_ui_config.py # Selector definitions
โ โ โโโ DerivedTypes/ # Chat, Message dataclasses
โ โโโ Interfaces/ # Abstract contracts (for future platforms)
โ โโโ StorageDB/ # Async SQLite with queue workers
โ โโโ Exceptions/ # Custom exception hierarchy
โโโ tests/ # >90% coverage on core modules
Key Design Decisions
- Interface-Driven: Every platform implements
ChatProcessorInterface,MessageProcessorInterface, etc. - Dependency Injection: All classes accept
logparameter for testability - Async-First: Non-blocking SQLite writes, background queue workers
- Anti-Detection: Camoufox fingerprints + human-like typing delays
๐ Modules
| Module | Description |
|---|---|
| BrowserManager | Anti-detect browser with fingerprint rotation |
| Login | QR code + phone number authentication |
| ChatProcessor | Fetch chats, handle unread status, click navigation |
| MessageProcessor | Extract messages, deduplicate, filter, store |
| SQLITE_DB | Async queue-powered storage with batch inserts |
| WebSelectorConfig | Platform-specific DOM selectors |
๐ ๏ธ How It Works
Message Processing Flow
1. ChatProcessor.Fetcher() โ yields Chat objects
2. MessageProcessor.Fetcher(chat) โ clicks chat, extracts messages
3. Messages wrapped as whatsapp_message dataclass
4. New messages enqueued to SQLITE_DB async queue
5. Background writer batches inserts every N seconds
Anti-Detection Stack
Playwright (base) โ Camoufox (fingerprint) โ BrowserForge (realistic profiles)
๐ค Contributing
We welcome contributions! Vibe coding accepted โ if it works and is clean, we'll merge it.
Contribution Rules
- Fork โ Branch โ PR workflow required
- AI-Assisted code is welcome โ just mention it in your PR description for transparency
- Tests required for new features (we maintain >90% coverage on core modules)
- Type hints required โ we use
mypyfor static analysis
Quick Start for Contributors
# Clone and setup
git clone https://github.com/BITS-Rohit/tweakio-sdk.git
cd tweakio-sdk
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
# Run tests
pytest --cov=src
# Your feature branch
git checkout -b feature/your-feature
PR Template
## What does this PR do?
[Description]
## AI Disclosure
- [ ] This PR includes AI-generated code (Claude/GPT/Copilot)
- [ ] This PR is fully human-written
## Testing
- [ ] Added/updated tests
- [ ] All tests pass locally
๐บ๏ธ Roadmap
v0.1.6 โ Core Infrastructure
- Custom Logger improvements
- Multi-Account Handling
- BrowserManager enhancements
- Dependency Injection & Interface renewal
- Directory structure improvements
- Separate Browser Logging
v0.1.7 โ Security & Stability
- Encryption & Decryption module
- KeyBox integration
- Stability & Decryptor additions
- Stability increase โ 60-70% reliability
v0.1.8 โ Quality Assurance
- Test coverage increase & logic improvements
- Web-UI tinkering & refinements
v0.2.0 โ Multi-Platform (Coming Soon)
- Another Platform integration (Telegram/Instagram)
- Platform-agnostic architecture
โ FAQ
Q: Will I get banned?
A: Tweakio uses Camoufox anti-detection. With reasonable rate limiting, bans are rare. Always test on disposable accounts first.
Q: Can I use this for spam?
A: No. This SDK is for legitimate automation (customer support, archiving, notifications). Spam violates WhatsApp ToS and is not supported.
Q: Why not just use the WhatsApp Business API?
A: Business API has message template restrictions and approval processes. Tweakio is for developers who need full control.
๐ License
MIT License โ see LICENSE
๐ Links
- PyPI: pypi.org/project/tweakio-sdk
- GitHub: github.com/BITS-Rohit/tweakio-sdk
- Issues: Report bugs
Keywords: tweakio, tweakio-sdk, whatsapp automation, whatsapp bot python, whatsapp api, web automation, playwright, browser automation, chatbot, messaging, anti-detection, camoufox
Built with โค๏ธ by BITS-Rohit and the Tweakio community
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
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 tweakio_sdk-0.1.5.tar.gz.
File metadata
- Download URL: tweakio_sdk-0.1.5.tar.gz
- Upload date:
- Size: 36.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29b4c3f06eb027242caaef6c49148b3abc21c77856465efbbb467778ac8c0a65
|
|
| MD5 |
f23b8ca1419a22b88c87a9cf03964364
|
|
| BLAKE2b-256 |
127d3b0a0e7a250fd1561eeb2a47897e524e94ea37a20b1129f18eb3dfbbe31c
|
File details
Details for the file tweakio_sdk-0.1.5-py3-none-any.whl.
File metadata
- Download URL: tweakio_sdk-0.1.5-py3-none-any.whl
- Upload date:
- Size: 38.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
498212a5ae62c373598a5e4f3e204ab310f4505ac5d8c75b4b4152fe113311c4
|
|
| MD5 |
677250785df80726d4336f0f799ba96e
|
|
| BLAKE2b-256 |
84ecc7cdc8121321732bdc0e8cf0dae180119324b7d70a6435d2d701c7181643
|