slacko
A comprehensive Rust SDK for the Slack API with support for both standard OAuth tokens and stealth mode authentication.
Features
- Multiple authentication methods: OAuth tokens (xoxp, xoxb) and stealth mode (xoxc/xoxd)
- Complete API coverage: 24 API modules covering all major Slack functionality
- Real-time messaging via WebSocket (RTM API)
- Block Kit builders for rich message layouts
- Strongly typed requests and responses
- Built on tokio for async/await support
- Automatic rate limit detection
Installation
Add to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["full"] }
Quick Start
OAuth Authentication
use ;
async
Stealth Mode Authentication
use ;
async
Environment Variables
# OAuth mode
# or
# Stealth mode
let client = new?;
API Examples
Chat
// Post message
client.chat.post_message.await?;
// Reply in thread
client.chat.post_reply.await?;
// Update message
client.chat.update_message.await?;
// Delete message
client.chat.delete_message.await?;
Conversations
// List channels
let channels = client.conversations.list.await?;
// Create channel
client.conversations.create.await?;
// Get history
let history = client.conversations.history.await?;
// Invite users
client.conversations.invite.await?;
Users
// List users
let users = client.users.list.await?;
// Get user info
let user = client.users.info.await?;
// Set presence
client.users.set_presence.await?;
Files
// Upload file
client.files.upload.await?;
// List files
let files = client.files.list.await?;
Reactions
// Add reaction
client.reactions.add.await?;
// Remove reaction
client.reactions.remove.await?;
Search
// Search messages
let results = client.search.messages.await?;
// Search files
let files = client.search.files.await?;
Real-Time Messaging
// Connect and listen for messages
client.rtm.start.await?;
Block Kit
use ;
let blocks = new
.add_header
.add_section
.add_divider
.add_actions
.build;
client.chat.post_message_with_blocks.await?;
API Modules
| 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 |
Error Handling
use SlackError;
match client.chat.post_message.await
Obtaining Tokens
OAuth Tokens (Recommended)
- Create a Slack App at https://api.slack.com/apps
- Add required OAuth scopes under "OAuth & Permissions"
- Install the app to your workspace
- Copy the Bot Token (xoxb-...) or User Token (xoxp-...)
Stealth Mode Tokens
Use the included browser extension for easy token extraction:
- Load the extension from
browser-extension/in Chrome (chrome://extensions > Load unpacked) - Navigate to your Slack workspace in the browser
- Click the extension icon and copy the tokens
Or extract manually:
- Open Slack in your browser
- Open Developer Tools (F12)
- Go to Application > Cookies, find the
dcookie (xoxd value) - Go to Network tab, find any API request with
tokenparameter (xoxc value)
Running Tests
# Set up credentials
# Edit .env with your tokens
# Run tests
License
MIT License. See LICENSE for details.