Open Source Libraries

Python

Connect to TikTok LIVE streams in real-time with the TikTokLive Python library.

|View as Markdown|

TikTokLive is a Python library for connecting to TikTok LIVE streams. It provides an async, event-driven API using decorators or manual listeners.

View the full source on GitHub.

Quickstart

1

Install the package

pip install TikTokLive
2

Set your API key

from TikTokLive.client.web.web_settings import WebDefaults

WebDefaults.tiktok_sign_api_key = "YOUR_API_KEY"
3

Connect and listen to events

from TikTokLive import TikTokLiveClient
from TikTokLive.events import ConnectEvent, CommentEvent

client: TikTokLiveClient = TikTokLiveClient(unique_id="@username")

@client.on(ConnectEvent)
async def on_connect(event: ConnectEvent):
    print(f"Connected to @{event.unique_id} (Room ID: {client.room_id})")

@client.on(CommentEvent)
async def on_comment(event: CommentEvent):
    print(f"{event.user.nickname} -> {event.comment}")

if __name__ == '__main__':
    client.run()

Blocking vs Non-Blocking

# Blocking (runs the event loop)
client.run()

# Non-blocking (use inside an async function)
await client.start()

Common Events

EventDescription
ConnectEventSuccessfully connected to the stream
CommentEventA viewer sent a chat message
GiftEventA viewer sent a gift
LikeEventA viewer liked the stream
JoinEventA viewer joined the stream
ShareEventA viewer shared the stream
FollowEventA viewer followed the creator
DisconnectEventDisconnected from the stream

See the API Key Usage guide for more configuration options.