TikTok-Live-Java
A Java library based on TikTok-Connector 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 package 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. Besides Chat Comments, other events such as Members Joining, Gifts, Subscriptions, Viewers, Follows, Shares, Questions, Likes and Battles can be tracked. You can also send automatic messages into the chat by providing your Session ID.
Do you prefer other programming languages?
- Node orginal: TikTok-Live-Connector by @isaackogan
- 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 via Maven
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.24.1</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>com.github.jwdeveloper</groupId>
<artifactId>TikTok-Live-Java</artifactId>
<version>0.0.10-Release</version>
</dependency>
</dependencies>
- Create your first chat connection
public static void main(String[] args)
{
// Username of someone who is currently live
var tiktokUsername = "officialgeilegisela";
TikTokLive.newClient(tiktokUsername)
.onConnected(event ->
{
System.out.println("Connected");
})
.onJoin(event ->
{
System.out.println("User joined -> " + event.getUser().getNickName());
})
.onComment(event ->
{
System.out.println(event.getUser().getUniqueId() + ": " + event.getText());
})
.onError(event ->
{
event.getException().printStackTrace();
})
.buildAndRun();
}
Methods
A TikTokLive object contains the following methods.
| Method Name | Description |
|---|---|
| connect | Connects to the live stream chat. Returns a Promise which will be resolved when the connection is successfully established. |
| disconnect | Disconnects the connection. |
| getRoomInfo | Gets the current room info from TikTok API including streamer info, room status and statistics. |
Events
A TikTokLive object has the following events
Events:
- TikTokUnhandledSocialEvent
- TikTokLinkMicFanTicketEvent
- TikTokEnvelopeEvent
- TikTokShopMessageEvent
- TikTokDetectMessageEvent
- TikTokLinkLayerMessageEvent
- TikTokConnectedEvent
- TikTokCaptionEvent
- TikTokQuestionEvent
- TikTokRoomPinMessageEvent
- TikTokRoomMessageEvent
- TikTokLivePausedEvent
- TikTokLikeEvent
- TikTokLinkMessageEvent
- TikTokBarrageMessageEvent
- TikTokGiftMessageEvent
- TikTokLinkMicArmiesEvent
- TikTokEmoteEvent
- TikTokUnauthorizedMemberEvent
- TikTokInRoomBannerEvent
- TikTokLinkMicMethodEvent
- TikTokSubscribeEvent
- TikTokPollMessageEvent
- TikTokFollowEvent
- TikTokRoomViewerDataEvent
- TikTokGoalUpdateEvent
- TikTokCommentEvent
- TikTokRankUpdateEvent
- TikTokIMDeleteEvent
- TikTokLiveEndedEvent
- TikTokErrorEvent
- TikTokUnhandledEvent
- TikTokJoinEvent
- TikTokRankTextEvent
- TikTokShareEvent
- TikTokUnhandledMemberEvent
- TikTokSubNotifyEvent
- TikTokLinkMicBattleEvent
- TikTokDisconnectedEvent
- TikTokGiftBroadcastEvent
- TikTokUnhandledControlEvent
- TikTokEvent
Contributing
Your improvements are welcome! Feel free to open an issue or pull request.