A Rust SDK for the Slack API Platform with type-safe, idiomatic interfaces.
- Web API Client - 287+ Slack API methods with sync and async support
- Block Kit - Type-safe UI components (blocks, elements, views)
- OAuth 2.0 - Complete OAuth flow with multiple storage backends
- Socket Mode - Real-time WebSocket events with auto-reconnection
- Webhooks - Incoming webhooks and response URLs
- Signature Verification - HMAC-SHA256 request validation
- HTTP Retry - Exponential backoff with rate limit handling
- SCIM API - User/group provisioning (Enterprise)
- Audit Logs API - Enterprise audit log access
[dependencies]
slack-rs = "0.1"tokio = { version = "1", features = ["full"] }use slack_rs::web::AsyncWebClient;#[tokio::main]asyncfnmain() -> Result<(),Box<dyn std::error::Error>>{let client = AsyncWebClient::new("xoxb-your-bot-token")?;let response = client.chat_post_message("#general","Hello from Rust!",None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,).await?;println!("Message sent: {:?}", response);Ok(())}use slack_rs::models::*;let blocks = vec![HeaderBlock::new("Daily Report")?.into(),DividerBlock::new().into(),SectionBlock::new("*Sales*: $1,234")?.into(),ActionsBlock::builder().elements(vec![ButtonElement::new("View Details","view_details").with_style(ButtonStyle::Primary).build()?
]).build()?
.into(),];use slack_rs::oauth::AuthorizeUrlGenerator;let generator = AuthorizeUrlGenerator::new("client_id").scopes(vec!["chat:write".to_string(),"channels:read".to_string()]).redirect_uri("https://your-app.com/oauth/callback");let auth_url = generator.generate("state-123",None);use slack_rs::socket_mode::SocketModeClient;letmut client = SocketModeClient::new("xapp-your-app-token");
client.connect().await?;See the examples/ directory for complete applications. Each example is a standalone Cargo project:
cd examples/basic_bot
SLACK_BOT_TOKEN=xoxb-your-token cargo runOptional features can be enabled in Cargo.toml:
[dependencies]
slack-rs = { version = "0.1", features = ["sqlite", "postgres", "mysql", "s3"] }sqlite- SQLite storage backend (default)postgres- PostgreSQL storage backendmysql- MySQL storage backends3- AWS S3 storage backendfull- All features
cargo test --all-features --workspace
cargo clippy --all-targets --all-features -- -D warnings
cargo fmt --check- Rust 1.75 or later
MIT License - see LICENSE file for details.
Inspired by the Python Slack SDK.