Quickstart

Get up and running with the Euler Stream API in under 5 minutes.

|View as Markdown|

This guide walks you through making your first connection to a TikTok LIVE stream using the Euler Stream API.

Prerequisites

Choose Your Language

1. Install the library

pip install TikTokLive

2. Connect to a livestream

from TikTokLive import TikTokLiveClient
from TikTokLive.client.web.web_settings import WebDefaults
from TikTokLive.events import ConnectEvent, CommentEvent

# Set your API key BEFORE creating the client
WebDefaults.tiktok_sign_api_key = "YOUR_API_KEY"

client = TikTokLiveClient(unique_id="@tv_asahi_news")

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

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

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

Replace YOUR_API_KEY with the API key from your dashboard. Replace @tv_asahi_news with any TikTok username that is currently live.

What Just Happened?

When you run the code above:

  1. The library sends your API key to the Euler Stream signing server
  2. The server generates an authenticated URL for the TikTok LIVE WebSocket
  3. The library connects to TikTok's WebSocket and starts receiving real-time events
  4. Your callback functions fire whenever a new event arrives (comments, gifts, joins, etc.)

Next Steps