| Crates.io | slacko |
| lib.rs | slacko |
| version | 0.2.2 |
| created_at | 2026-01-02 05:15:09.015912+00 |
| updated_at | 2026-01-03 09:45:38.400536+00 |
| description | Comprehensive Rust SDK for the Slack API with stealth mode support |
| homepage | https://github.com/jimmystridh/slacko |
| repository | https://github.com/jimmystridh/slacko |
| max_upload_size | |
| id | 2018002 |
| size | 587,553 |
A comprehensive Rust SDK for the Slack API with support for both standard OAuth tokens and stealth mode authentication.
Add to your Cargo.toml:
[dependencies]
slacko = "0.1"
tokio = { version = "1", features = ["full"] }
use slacko::{SlackClient, AuthConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Using a bot token
let client = SlackClient::new(AuthConfig::bot("xoxb-your-token"))?;
// Post a message
client.chat().post_message("#general", "Hello from Rust!").await?;
// List channels
let channels = client.conversations().list().await?;
for channel in channels.channels {
println!("#{}", channel.name.unwrap_or_default());
}
Ok(())
}
use slacko::{SlackClient, AuthConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = SlackClient::new(
AuthConfig::stealth("xoxc-your-token", "xoxd-your-cookie")
)?;
let user = client.auth().test().await?;
println!("Authenticated as {}", user.user);
Ok(())
}
# OAuth mode
export SLACK_BOT_TOKEN=xoxb-...
# or
export SLACK_TOKEN=xoxp-...
# Stealth mode
export SLACK_XOXC_TOKEN=xoxc-...
export SLACK_XOXD_COOKIE=xoxd-...
let client = SlackClient::new(AuthConfig::from_env()?)?;
// Post message
client.chat().post_message("#general", "Hello!").await?;
// Reply in thread
client.chat().post_reply("#general", "1234567890.123456", "Reply").await?;
// Update message
client.chat().update_message("#general", "1234567890.123456", "Updated").await?;
// Delete message
client.chat().delete_message("#general", "1234567890.123456").await?;
// List channels
let channels = client.conversations().list().await?;
// Create channel
client.conversations().create("new-channel", false).await?;
// Get history
let history = client.conversations().history("C12345678").await?;
// Invite users
client.conversations().invite("C12345678", &["U12345678"]).await?;
// List users
let users = client.users().list().await?;
// Get user info
let user = client.users().info("U12345678").await?;
// Set presence
client.users().set_presence("away").await?;
// Upload file
client.files().upload(content, "file.pdf", Some(&["C12345678"])).await?;
// List files
let files = client.files().list().await?;
// Add reaction
client.reactions().add("C12345678", "1234567890.123456", "thumbsup").await?;
// Remove reaction
client.reactions().remove("C12345678", "1234567890.123456", "thumbsup").await?;
// Search messages
let results = client.search().messages("query").await?;
// Search files
let files = client.search().files("filename").await?;
// Connect and listen for messages
client.rtm().start(|message| {
println!("Received: {:?}", message.text);
}).await?;
use slacko::{MessageBuilder, SectionBlock, TextObject, ActionsBlock, ButtonElement};
let blocks = MessageBuilder::new()
.add_header(HeaderBlock::new("Status Update"))
.add_section(
SectionBlock::new(TextObject::markdown("*Build succeeded*"))
)
.add_divider()
.add_actions(
ActionsBlock::new()
.add_button(ButtonElement::new("view", "View Details"))
)
.build();
client.chat().post_message_with_blocks("#general", "Build update", blocks).await?;
| Module | Description |
|---|---|
admin |
Enterprise Grid administration |
apps |
App management and permissions |
auth |
Authentication verification |
bookmarks |
Channel bookmarks |
calls |
Slack Calls integration |
chat |
Messages and threads |
conversations |
Channels, DMs, and groups |
dialog |
Legacy dialogs |
dnd |
Do Not Disturb settings |
emoji |
Custom emoji |
files |
File uploads and management |
oauth |
OAuth token exchange |
openid |
OpenID Connect authentication |
pins |
Pinned messages |
reactions |
Emoji reactions |
reminders |
Reminders |
rtm |
Real-time messaging |
search |
Message and file search |
stars |
Starred items |
team |
Team information |
usergroups |
User groups |
users |
User information and presence |
views |
Modals and App Home |
workflows |
Workflow Builder |
use slacko::SlackError;
match client.chat().post_message("#general", "Hello").await {
Ok(response) => println!("Sent: {}", response.ts),
Err(SlackError::RateLimitExceeded { retry_after }) => {
println!("Rate limited, retry after {} seconds", retry_after);
}
Err(SlackError::ApiError { method, message }) => {
println!("API error in {}: {}", method, message);
}
Err(e) => println!("Error: {}", e),
}
Use the included browser extension for easy token extraction:
browser-extension/ in Chrome (chrome://extensions > Load unpacked)Or extract manually:
d cookie (xoxd value)token parameter (xoxc value)# Set up credentials
cp .env.example .env
# Edit .env with your tokens
# Run tests
cargo test --tests
MIT License. See LICENSE for details.