16 releases (stable)

Uses new Rust 2024

6.0.0 Mar 30, 2026
5.0.1 Aug 29, 2023
5.0.0 Oct 4, 2022
4.1.0 Sep 20, 2022
0.3.0 Nov 24, 2020

#343 in Network programming

Download history 424/week @ 2025-12-28 550/week @ 2026-01-04 235/week @ 2026-01-11 364/week @ 2026-01-18 398/week @ 2026-01-25 499/week @ 2026-02-01 361/week @ 2026-02-08 738/week @ 2026-02-15 1405/week @ 2026-02-22 1390/week @ 2026-03-01 1285/week @ 2026-03-08 1804/week @ 2026-03-15 1581/week @ 2026-03-22 1533/week @ 2026-03-29 1194/week @ 2026-04-05 1716/week @ 2026-04-12

6,225 downloads per month
Used in 5 crates

MIT license

355KB
6K SLoC

twitch-irc-rs

Rust CI status Crates.io Docs.rs

This is a client library to interface with Twitch chat.

This library is async and runs using the tokio runtime.

Example usage (This is the simple_listener example, see examples/simple_listener.rs and run it with cargo run --example simple_listener):

use twitch_irc::login::StaticLoginCredentials;
use twitch_irc::TwitchIRCClient;
use twitch_irc::{ClientConfig, SecureTCPTransport};

#[tokio::main]
pub async fn main() {
    // default configuration is to join chat as anonymous.
    let config = ClientConfig::default();
    let (mut incoming_messages, client) =
        TwitchIRCClient::<SecureTCPTransport, StaticLoginCredentials>::new(config);

    // first thing you should do: start consuming incoming messages,
    // otherwise they will back up.
    let join_handle = tokio::spawn(async move {
        while let Some(message) = incoming_messages.recv().await {
            println!("Received message: {:?}", message);
        }
    });

    // join a channel
    // This function only returns an error if the passed channel login name is malformed,
    // so in this simple case where the channel name is hardcoded we can ignore the potential
    // error with `unwrap`.
    client.join("sodapoppin".to_owned()).unwrap();

    // keep the tokio executor alive.
    // If you return instead of waiting the background task will exit.
    join_handle.await.unwrap();
}

Check out the documentation on docs.rs for more details.

Dependencies

~8–30MB
~358K SLoC