A Rust library. Use it to receive live stream events such as comments and gifts in realtime from TikTok LIVE No credentials are required.
Join the support discord and visit the #rust-support
channel for questions, contributions and ideas. Feel free to make pull requests with missing/new features, fixes, etc
Do you prefer other programming languages?
- Java TikTokLiveJava
- Node TikTok-Live-Connector by @zerodytrash
- Python TikTokLive by @isaackogan
- C# TikTokLiveSharp by @frankvHoof93
NOTE: This is not an official API. It's a reverse engineering project.
[dependencies]
tiktoklive = "0.0.5"
#[tokio::main]
async fn main() {
let user_name = "dash4214";
let mut client = TikTokLive::new_client(user_name)
.configure(configure)
.on_event(handle_event)
.build();
client.connect().await;
let mut input = String::new();
if io::stdin().read_line(&mut input).is_ok() && input.trim() == "stop"
{
//client.disconnect();
}
}
fn handle_event(client: &TikTokLiveClient, event: &TikTokLiveEvent)
{
match event {
TikTokLiveEvent::OnMember(joinEvent) =>
{
println!("user: {} joined", joinEvent.raw_data.user.nickname);
}
TikTokLiveEvent::OnChat(chatEvent) =>
{
println!("user: {} -> {} ", chatEvent.raw_data.user.nickname, chatEvent.raw_data.content);
}
TikTokLiveEvent::OnGift(giftEvent) =>
{
let nick = &giftEvent.raw_data.user.nickname;
let gift_name = &giftEvent.raw_data.gift.name;
let gifts_amount = giftEvent.raw_data.gift.combo;
println!("user: {} sends gift: {} x {}", nick, gift_name, gifts_amount);
}
_ => {}
}
}
fn configure(settings: &mut TikTokLiveSettings)
{
settings.http_data.time_out = Duration::from_secs(12);
}
Your improvements are welcome! Feel free to open an issue or pull request.