Expand description
A Rust library for the Twitch Helix API with type safety and comprehensive EventSub support.
Official Twitch API Documentation: https://dev.twitch.tv/docs/api/reference/
§Getting Started
§Basic Usage
use twitch_highway::{
moderation::ModerationAPI,
types::{BroadcasterId, ModeratorId, UserId},
AccessToken, ClientId,
};
let api = twitch_highway::Client::new(
AccessToken::from("your_access_token"),
ClientId::from("your_client_id"),
);
let response = api
.ban_user(
&BroadcasterId::from("12345"),
&ModeratorId::from("67890"),
&UserId::from("54321"),
)
.duration(600) // Optional: 10 minutes
.reason("no reason") // Optional
.send()
.await?;
println!("User banned successfully");§Error Handling
match api.get_videos(&UserId::from("123")).send().await {
Ok(response) => {
// Process successful response
}
Err(e) => {
if e.is_request() {
// Network or connection error
eprintln!("Request failed: {}", e);
} else if e.is_api() {
// Twitch API returned an error (4xx, 5xx)
eprintln!("API error: {}", e);
} else if e.is_parse() {
// Failed to parse response
eprintln!("JSON decode error: {}", e);
}
}
}§EventSub Integration
Comprehensive support for both Webhook and WebSocket transports.
§Webhook Verification
- HMAC-SHA256 signature verification
- Framework integrations: axum, actix-web
- Custom implementations via
HeaderAccesstrait
§Feature Flags
webhook-axum: Axum framework supportwebhook-actix: Actix-web framework support
§WebSocket Client
- Automatic reconnection with exponential backoff
- Keepalive message handling
- Type-safe event routing (similar to axum)
- Middleware support (logging, rate limiting)
§Feature Flags
websocket: WebSocket client with reconnection and event routing
See the eventsub module documentation for more details.
§OAuth Token Management
This library is designed to work with twitch_oauth_token for OAuth authentication.
Modules§
- ads
- analytics
- bits
- ccls
- channel_
points - channels
- charity
- chat
- clips
- conduits
- entitlements
- eventsub
- extensions
- games
- goals
- guest_
star - hype_
train - moderation
- polls
- predictions
- raid
- schedule
- search
- streams
- subscriptions
- teams
- types
- users
- videos
- whisper