| Crates.io | twitch_highway |
| lib.rs | twitch_highway |
| version | 0.2.1 |
| created_at | 2024-03-02 04:54:10.539756+00 |
| updated_at | 2025-08-23 23:31:39.656504+00 |
| description | Twitch API |
| homepage | |
| repository | https://github.com/m3idnotfree/twitch_highway.git |
| max_upload_size | |
| id | 1159489 |
| size | 757,969 |
A Rust library for Twitch API with compile-time safety and comprehensive response support.
[dependencies]
# Add the endpoints you need: "chat", "users", etc.
twitch_highway = { version = "1", features = ["moderation"]}
tokio = { version = "1", features = ["full"] }
asknothingx2-util = { version = "0.1", features = ["oauth"] }
# or
# twitch_oauth_token = { version = "2.0.1" }
use asknothingx2_util::oauth::{AccessToken, ClientId};
// or
// use twitch_oauth_token::oauth_types::{AccessToken, ClientId};
use twitch_highway::{
moderation::{request::BanUserRequest, ModerationAPI},
types::{BroadcasterId, ModeratorId, UserId},
TwitchAPI,
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error> {
let api = TwitchAPI::new(
AccessToken::new("access_token".to_string()),
ClientId::new("client_id".to_string()),
);
let broadcaster_id = BroadcasterId::new("broadcaster_id");
let moderator_id = ModeratorId::new("moderator_id");
let user_id = UserId::new("9876");
let ban_user = api.ban_user(
&broadcaster_id,
&moderator_id,
BanUserRequest::new(&user_id).reason("no reason"),
);
let response = ban_user.json().await;
match response {
Ok(success) => { /* */ }
Err(e) => {
if e.is_api() {
println!("API error: {}", e);
} else if e.is_request() {
println!("Request error: {}", e);
} else if e.is_decode() {
println!("JSON decode error: {}", e);
}
}
}
Ok(())
}
Note: Conduits and EventSub are not implemented yet, but are planned for future releases.
Licensed under the MIT license.