| Crates.io | whatsapp-rust |
| lib.rs | whatsapp-rust |
| version | 0.2.0 |
| created_at | 2025-10-07 20:30:31.901311+00 |
| updated_at | 2025-12-26 20:28:19.459613+00 |
| description | Rust client for WhatsApp Web |
| homepage | |
| repository | https://github.com/jlucaso1/whatsapp-rust |
| max_upload_size | |
| id | 1872808 |
| size | 818,213 |
A high-performance, async Rust library for the WhatsApp Web API. Inspired by whatsmeow (Go) and Baileys (TypeScript).
use std::sync::Arc;
use whatsapp_rust::bot::Bot;
use whatsapp_rust::store::SqliteStore;
use whatsapp_rust_tokio_transport::TokioWebSocketTransportFactory;
use whatsapp_rust_ureq_http_client::UreqHttpClient;
use wacore::types::events::Event;
#[tokio::main]
async fn main() {
let backend = Arc::new(SqliteStore::new("whatsapp.db").await.unwrap());
let mut bot = Bot::builder()
.with_backend(backend)
.with_transport_factory(TokioWebSocketTransportFactory::new())
.with_http_client(UreqHttpClient::new())
.on_event(|event, client| async move {
match event {
Event::PairingQrCode { code, .. } => println!("QR:\n{}", code),
Event::Message(msg, info) => {
println!("Message from {}: {:?}", info.source.sender, msg);
}
_ => {}
}
})
.build()
.await
.unwrap();
bot.run().await.unwrap().await.unwrap();
}
Run the included demo bot:
cargo run # QR code only
cargo run -- -p 15551234567 # Pair code + QR code
cargo run -- -p 15551234567 -c 12345678 # Custom pair code
whatsapp-rust/
├── src/ # Main client library
├── wacore/ # Platform-agnostic core (no_std compatible)
│ ├── binary/ # WhatsApp binary protocol
│ ├── libsignal/ # Signal Protocol implementation
│ └── appstate/ # App state management
├── waproto/ # Protocol Buffers definitions
├── storages/sqlite-storage # SQLite backend
├── transports/tokio-transport
└── http_clients/ureq-client
Implement your own storage, transport, or HTTP client by implementing the respective traits. See the default implementations for reference.
This is an unofficial, open-source reimplementation. Using custom WhatsApp clients may violate Meta's Terms of Service and could result in account suspension. Use at your own risk.