RuWa
WhatsApp Web API dalam Rust - Library paling lengkap untuk membuat bot WhatsApp
📬 Kontak Developer
🤖 Note: Dokumentasi dibuat dengan AI. Found a bug? Contact developer!
🎯 Kenapa RuWa?
| Feature | RuWa | Library Lain |
|---|---|---|
| Performance | ⚡ Rust (native speed) | 🐢 Node.js/Python |
| Memory Usage | 💾 < 50MB | 📦 200MB+ |
| Type Safety | ✅ Compile-time checks | ❌ Runtime errors |
| E2E Encryption | ✅ Signal Protocol | ✅ Varies |
| Multi-device | ✅ Up to 4 devices | ⚠️ Limited |
| Documentation | 📖 Complete | ⚠️ Incomplete |
📑 Table of Contents
- 🚀 Quick Start - Mulai dalam 5 menit
- 📦 Instalasi Lengkap - Step-by-step
- ✨ Fitur Lengkap - Semua yang tersedia
- 🔐 Autentikasi - QR & Pair code
- 💬 Messaging - Kirim & terima pesan
- 📸 Media - Upload & download
- 👥 Grup Management
- 📊 Presence & Receipts
- ⚙️ Advanced Usage
- 🐛 Troubleshooting
- ❓ FAQ
- ⚠️ Disclaimer
🚀 Quick Start
Mulai dalam 5 Menit
# 1. Clone atau buat project baru
# 2. Tambahkan dependencies
Contoh Bot Sederhana
// src/main.rs
use Bot;
use SqliteStore;
use TokioWebSocketTransportFactory;
use UreqHttpClient;
use Event;
async
Jalankan
# Run dengan QR code
# Run dengan pair code (nomor telepon)
# Run dengan custom pair code
📦 Instalasi Lengkap
1. Cargo.toml
[]
= "my-whatsapp-bot"
= "0.1.0"
= "2021"
[]
# RuWa core
= "1.0.0"
# Storage (pilih salah satu)
= "1.0.0" # SQLite (recommended)
# Transport
= "1.0.0" # WebSocket
# HTTP Client
= "1.0.0"
# Async runtime
= { = "1.48", = ["full"] }
# Utilities
= "0.4"
= "0.11"
= "0.4"
2. System Requirements
# Install Rust (Linux/Mac)
|
# Install Rust (Windows)
# Download dari https://rustup.rs/
# Install Rust (Termux/Android)
# Install protoc (Protocol Buffers)
# Ubuntu/Debian
# macOS
# Windows
# Download dari https://github.com/protocolbuffers/protobuf/releases
# Verify installation
3. Build & Run
# Development build
# Release build (optimized)
# Run
# Run with logging
RUST_LOG=info
✨ Fitur Lengkap
🔐 Autentikasi
| Method | Deskripsi | Status |
|---|---|---|
| QR Code | Scan QR dari WhatsApp | ✅ Ready |
| Pair Code | 8-digit code via phone | ✅ Ready |
| Session Persist | Auto-reconnect | ✅ Ready |
| Multi-device | Link up to 4 devices | ✅ Ready |
💬 Messaging
| Feature | Status | Example |
|---|---|---|
| Text messages | ✅ | conversation: Some("Hello") |
| Image messages | ✅ | image_message: Some(...) |
| Video messages | ✅ | video_message: Some(...) |
| Audio messages | ✅ | audio_message: Some(...) |
| Document messages | ✅ | document_message: Some(...) |
| Location messages | ✅ | location_message: Some(...) |
| Contact messages | ✅ | contact_message: Some(...) |
| Sticker messages | ⚠️ | Partial support |
| Edit messages | ✅ | edit_message(id, new_msg) |
| Delete messages | ✅ | revoke_message(id) |
| Reply/Quote | ✅ | context_info: Some(...) |
| Reactions | ✅ | reaction_message: Some(...) |
📸 Media
| Type | Upload | Download | Status |
|---|---|---|---|
| Images | ✅ | ✅ | Full support |
| Videos | ✅ | ✅ | Full support |
| Audio | ✅ | ✅ | Full support |
| Documents | ✅ | ✅ | Full support |
| GIFs | ✅ | ✅ | Full support |
| Stickers | ⚠️ | ⚠️ | Partial |
👥 Grup
| Feature | Status | Method |
|---|---|---|
| Create group | ✅ | groups().create() |
| List groups | ✅ | groups().list() |
| Get metadata | ✅ | groups().get_metadata() |
| Add participants | ✅ | groups().add_participants() |
| Remove participants | ✅ | groups().remove_participants() |
| Promote to admin | ✅ | groups().promote_participants() |
| Demote admin | ✅ | groups().demote_participants() |
| Update subject | ✅ | groups().set_subject() |
| Update description | ✅ | groups().set_description() |
| Set ephemeral | ✅ | groups().set_ephemeral() |
| Invite link | ✅ | groups().get_invite_link() |
| Leave group | ✅ | groups().leave() |
📊 Presence & Receipts
| Feature | Status |
|---|---|
| Set online/offline | ✅ |
| Subscribe presence | ✅ |
| Typing indicator | ✅ |
| Recording indicator | ✅ |
| Read receipts | ✅ |
| Delivery receipts | ✅ |
| Played receipts (audio) | ✅ |
🔐 Autentikasi Detail
Method 1: QR Code (Default)
builder
.with_backend
.on_event
.build
.await?
Method 2: Pair Code (Phone Number)
use ;
use PlatformId;
builder
.with_backend
.with_pair_code
.on_event
.build
.await?
Method 3: Session Persist (Auto-login)
// Session otomatis tersimpan di database
// Restart aplikasi = auto reconnect tanpa pairing ulang
let bot = builder
.with_backend
.build
.await?;
// Jika session masih valid, langsung connected
// Jika expired, akan trigger QR/Pair code
💬 Messaging Detail
Kirim Pesan Teks
use Jid;
use whatsapp as wa;
let chat_id: Jid = "6281234567890@s.whatsapp.net".parse?;
let msg_id = client.send_message.await?;
println!;
Reply/Quote Pesan
use build_quote_context;
// Build quote context
let quote_context = build_quote_context;
// Kirim reply
client.send_message.await?;
Reaction (Emoji)
use Utc;
client.send_message.await?;
Edit Pesan
let new_message = Message ;
client.edit_message.await?;
Delete Pesan (Revoke)
use RevokeType;
// Delete pesan sendiri
client.revoke_message.await?;
// Admin delete pesan user lain (di grup)
client.revoke_message.await?;
Forward Pesan
// Forward ke chat lain
client.send_message.await?;
📸 Media Detail
Upload & Kirim Gambar
use MediaType;
// 1. Baca file
let image_data = read?;
// 2. Upload ke WhatsApp server
let upload = client.upload.await?;
// 3. Build message
let message = Message ;
// 4. Kirim
client.send_message.await?;
Download Media
use ;
use Cursor;
// Dapatkan message yang punya media
if let Some = &message.image_message
Upload Video
let video_data = read?;
let upload = client.upload.await?;
client.send_message.await?;
Upload Audio/Voice Note
let audio_data = read?;
let upload = client.upload.await?;
client.send_message.await?;
Upload Document
let doc_data = read?;
let upload = client.upload.await?;
client.send_message.await?;
👥 Grup Management Detail
Buat Grup Baru
use ;
let participants = vec!;
let result = client.groups.create.await?;
println!;
Dapatkan Info Grup
let metadata = client.groups.get_metadata.await?;
println!;
println!;
println!;
println!;
// List participants
for participant in &metadata.participants
Manage Participants
let groups = client.groups;
// Add participants
groups.add_participants.await?;
// Remove participants
groups.remove_participants.await?;
// Promote to admin
groups.promote_participants.await?;
// Demote admin
groups.demote_participants.await?;
Update Group Settings
let groups = client.groups;
// Update nama
groups.set_subject.await?;
// Update deskripsi
groups.set_description.await?;
// Set disappearing messages (24 jam)
groups.set_ephemeral.await?;
// Disable disappearing messages
groups.set_ephemeral.await?;
// Get invite link
let invite_link = groups.get_invite_link.await?;
println!;
// Revoke invite link
groups.revoke_invite_link.await?;
// Leave group
groups.leave.await?;
📊 Presence & Receipts
Set Presence
// Set online
client.presence.set_available.await?;
// Set offline
client.presence.set_available.await?;
// Subscribe presence kontak
client.presence.subscribe_presence.await?;
// Unsubscribe
client.presence.unsubscribe_presence.await?;
Typing Indicator
use ;
// Mulai mengetik
client.chatstate.send_chatstate.await?;
// Stop mengetik (auto setelah 3 detik)
client.chatstate.send_chatstate.await?;
// Recording audio
client.chatstate.send_chatstate.await?;
Handle Receipts
.on_event
⚙️ Advanced Usage
Custom Event Handler
use Bot;
use Arc;
let bot = builder
.with_backend
.on_event
.build
.await?;
Multiple Clients
// Run multiple bots/accounts
let bot1 = builder
.with_backend
.build
.await?;
let bot2 = builder
.with_backend
.build
.await?;
// Run concurrently
try_join!?;
Custom Cache Config
use ;
use Duration;
let cache_config = CacheConfig ;
let bot = builder
.with_backend
.with_cache_config
.build
.await?;
🐛 Troubleshooting
Build Errors
Error: SIMD feature requires nightly
Problem:
error[E0554]: `#![feature]` may not be used on the stable release channel
Solution: Feature SIMD sudah di-disable by default. Pastikan tidak enable SIMD di Cargo.toml:
# ❌ Jangan enable SIMD
= { = "1.0.0", = ["simd"] }
# ✅ Gunakan default (tanpa SIMD)
= "1.0.0"
Error: protoc not found
Problem:
failed to execute command: protoc: No such file or directory
Solution:
# Ubuntu/Debian
# macOS
# Verify
Runtime Errors
QR Code tidak muncul
Problem: Event PairingQrCode tidak trigger
Solution:
- Pastikan session lama dihapus:
rm whatsapp.db - Check event handler sudah benar
- Enable logging:
RUST_LOG=debug cargo run
Connection failed
Problem:
Error: Connection refused
Solution:
- Check internet connection
- Check firewall tidak block WebSocket
- Session expired, delete database dan pair ulang
Message tidak terkirim
Problem: send_message return error
Solution:
- Pastikan recipient JID benar:
number@s.whatsapp.net - Check session sudah established (tunggu retry receipt)
- Untuk grup, pastikan bot masih member
Performance Issues
Memory usage tinggi
Solution:
# Build release untuk optimasi
# Profile release di Cargo.toml
[]
= 3
= true
Slow message processing
Solution:
// Process messages async
.on_event
❓ FAQ
❌ TIDAK. Ini adalah unofficial library hasil reverse engineering WhatsApp Web. Penggunaan dapat melanggar ToS WhatsApp.
⚠️ YA, ada kemungkinan. WhatsApp dapat detect client tidak resmi dan melakukan suspend/ban.
Tips untuk minimize risk:
- Jangan spam
- Jangan kirim message massal
- Gunakan delay antar message
- Hanya untuk testing/development
✅ Support semua platform:
- Linux
- macOS
- Windows
- Android (via Termux)
📊 Ukuran approximate:
- Debug build: ~300MB
- Release build: ~50MB (dengan LTO)
✅ Ya, support hingga 4 perangkat companion (seperti WhatsApp Web linked devices).
✅ Sangat bisa! Library ini dirancang khusus untuk memudahkan pembuatan bot WhatsApp dengan berbagai fitur lengkap.
✅ Lihat folder examples/ di repository atau contoh di section Quick Start.
📬 Hubungi developer via kontak di atas atau buat issue di GitHub.
⚠️ Disclaimer
⚠️ PENTING: Gunakan dengan risiko sendiri!
Legal Notice
Library ini adalah UNOFFICIAL implementasi WhatsApp Web API. Penggunaan library ini dapat:
- ❌ Melanggar WhatsApp Terms of Service
- ❌ Melanggar WhatsApp Business Policy
- ⚠️ Mengakibatkan suspend atau ban akun WhatsApp Anda
Recommended Usage
✅ GUNAKAN HANYA UNTUK:
- Testing & development
- Educational purposes
- Research
- Personal projects (dengan risiko sendiri)
❌ JANGAN GUNAKAN UNTUK:
- Spam atau bulk messaging
- Scam atau fraud
- Aktivitas ilegal
- Pelanggaran privasi orang lain
- Commercial use tanpa izin dari Meta
No Warranty
Library ini disediakan "AS IS" tanpa warranty apapun. Developer tidak bertanggung jawab atas:
- Kerugian yang timbul dari penggunaan
- Suspend/ban akun
- Kehilangan data
- Masalah hukum yang mungkin timbul
📚 Resources
| Resource | Link |
|---|---|
| 📖 API Documentation | docs.rs/ruwa |
| 💻 Source Code | github.com/jrevanaldi-ai/ruwa |
| 📦 Package Registry | crates.io/crates/ruwa |
| 🐛 Issue Tracker | GitHub Issues |
| 💬 Discussions | GitHub Discussions |
🙏 Acknowledgements
Terima kasih kepada project yang menginspirasi:
- whatsmeow - Go WhatsApp library (tulir)
- Baileys - TypeScript WhatsApp library
- WhatsApp Web - Sebagai referensi protokol
📬 Still Have Questions?
Copyright © 2026 Nathan
Made with ❤️ using Rust