TikTokLiveJava
Java implementation of TikTok-Live-Connector library. Receive live stream events (comments, gifts, etc.) in realtime from TikTok LIVE.
Install / Use
/learn @jwdeveloper/TikTokLiveJavaREADME
❤️❤️🎁 Connect to TikTok live in 3 lines 🎁❤️❤️
<div align="center" > <a href="https://jitpack.io/#jwdeveloper/TikTok-Live-Java" target="blank" > <img src="https://jitpack.io/v/jwdeveloper/TikTok-Live-Java.svg" width="20%" > </a> <a href="https://discord.gg/e2XwPNTBBr" target="blank" > <img src="https://img.shields.io/badge/Discord-%235865F2.svg?style=for-the-badge&logo=discord&logoColor=white" > </a> <a target="blank" > <img src="https://img.shields.io/badge/java-%23ED8B00.svg?style=for-the-badge&logo=openjdk&logoColor=white" > </a> </div> </div>Introduction
A Java library inspired by TikTokLive and TikTokLiveSharp. Use it to receive live stream events such as comments and gifts in realtime from TikTok LIVE by connecting to TikTok's internal WebCast push service.
The library includes a wrapper that connects to the WebCast service using just the username (uniqueId). This allows you to connect to your own live chat as well as the live chat of other streamers.
No credentials are required. Events such as Members Joining, Gifts, Subscriptions, Viewers, Follows, Shares, Questions, Likes and Battles can be tracked.
Join the support discord and visit the #java-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?
- Node orginal: TikTok-Live-Connector by @zerodytrash
- Rust rewrite: TikTokLiveRust
- Python rewrite: TikTokLive by @isaackogan
- Go rewrite: GoTikTokLive by @Davincible
- C# rewrite: TikTokLiveSharp by @frankvHoof93
NOTE: This is not an official API. It's a reverse engineering project.
Overview
Getting started
- Install the package
Maven
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.jwdeveloper.TikTok-Live-Java</groupId>
<artifactId>Client</artifactId>
<version>1.11.0-Release</version>
<scope>compile</scope>
</dependency>
</dependencies>
Gradle
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.jwdeveloper.TikTok-Live-Java:Client:1.10.0-Release'
}
- Create your first chat connection
TikTokLive.newClient("bangbetmenygy")
.onGift((liveClient, event) ->
{
String message = switch (event.getGift()) {
case ROSE -> "ROSE!";
case GG -> "GOOD GAME";
case TIKTOK -> "Ye";
case CORGI -> "Nice gift";
default -> "Thank you for " + event.getGift().getName();
};
System.out.println(event.getUser().getProfileName() + " sends " + message);
})
.onGiftCombo((liveClient, event) ->
{
System.out.println(event.getComboState()+ " " + event.getCombo() + " " + event.getGift().getName());
})
.onRoomInfo((liveClient, event) ->
{
var roomInfo = event.getRoomInfo();
System.out.println("Room Id: "+roomInfo.getRoomId());
System.out.println("Likes: "+roomInfo.getLikesCount());
System.out.println("Viewers: "+roomInfo.getViewersCount());
})
.onJoin((liveClient, event) ->
{
System.out.println(event.getUser().getProfileName() + "Hello on my stream! ");
})
.onConnected((liveClient, event) ->
{
System.out.println("Connected to live ");
})
.onError((liveClient, event) ->
{
System.out.println("Error! " + event.getException().getMessage());
})
.buildAndConnect();
- Configure (optional)
TikTokLive.newClient("bangbetmenygy")
.configure((settings) ->
{
settings.setHostName("bangbetmenygy"); // This method is useful in case you want change hostname later
settings.setClientLanguage("en"); // Language
settings.setTimeout(Duration.ofSeconds(2)); // Connection timeout
settings.setLogLevel(Level.ALL); // Log level
settings.setPrintToConsole(true); // Printing all logs to console even if log level is Level.OFF
settings.setRetryOnConnectionFailure(true); // Reconnecting if TikTok user is offline
settings.setRetryConnectionTimeout(Duration.ofSeconds(1)); // Timeout before next reconnection
//Optional: Sometimes not every message from chat are send to TikTokLiveJava to fix this issue you can set sessionId
// documentation how to obtain sessionId https://github.com/isaackogan/TikTok-Live-Connector#send-chat-messages
settings.setSessionId("86c3c8bf4b17ebb2d74bb7fa66fd0000");
//Optional:
//RoomId can be used as an override if you're having issues with HostId.
//You can find it in the HTML for the livestream-page
settings.setRoomId("XXXXXXXXXXXXXXXXX");
})
.buildAndConnect();
//
Events
Events
Control:
Message:
- onEvent
- onEvent
- onComment
- onRoomInfo
- onGift
- onSubscribe
- onFollow
- onGiftCombo
- onLiveEnded
- onQuestion
- onShare
- onLiveUnpaused
- onEmote
- onJoin
- onLike
- onLivePaused
Debug:
Examples
<br>onReconnecting TikTokReconnectingEvent
TikTokLive.newClient("host-name")
.onReconnecting((liveClient, event) ->
{
})
.buildAndConnect();
<br>
onError TikTokErrorEvent
General error event. You should handle this.
TikTokLive.newClient("host-name")
.onError((liveClient, event) ->
{
})
.buildAndConnect();
<br>
onConnected TikTokConnectedEvent
Triggered when the connection is successfully established.
TikTokLive.newClient("host-name")
.onConnected((liveClient, event) ->
{
})
.buildAndConnect();
<br>
onDisconnected TikTokDisconnectedEvent
Triggered when the connection gets disconnected. In that case you can call connect() again to have a reconnect logic. Note that you should wait a little bit before attempting a reconnect to to avoid being rate-limited.
TikTokLive.newClient("host-name")
.onDisconnected((liveClient, event) ->
{
})
.buildAndConnect();
<br>
onEvent TikTokEvent
Base class for all events
TikTokLive.newClient("host-name")
.onEvent((liveClient, event) ->
{
})
.buildAndConnect();
<br>
onEvent [TikTokEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/jav
Related Skills
canvas
327.7kCanvas Skill Display HTML content on connected OpenClaw nodes (Mac app, iOS, Android). Overview The canvas tool lets you present web content on any connected node's canvas view. Great for: -
gh-issues
327.7kFetch GitHub issues, spawn sub-agents to implement fixes and open PRs, then monitor and address PR review comments. Usage: /gh-issues [owner/repo] [--label bug] [--limit 5] [--milestone v1.0] [--assignee @me] [--fork user/repo] [--watch] [--interval 5] [--reviews-only] [--cron] [--dry-run] [--model glm-5] [--notify-channel -1002381931352]
node-connect
327.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
openai-image-gen
327.7kBatch-generate images via OpenAI Images API. Random prompt sampler + `index.html` gallery.
