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

## Prerequisites

- An Euler Stream account ([sign up here](/register))
- An API key from the [Dashboard](/dashboard)

## Choose Your Language

<Tabs items={["Python", "Node.js", "Java", "Go"]}>
<Tab value="Python">

### 1. Install the library

```bash
pip install TikTokLive
```

### 2. Connect to a livestream

```python
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()
```

</Tab>
<Tab value="Node.js">

### 1. Install the library

```bash
npm install tiktok-live-connector
```

### 2. Connect to a livestream

```javascript
const { WebcastPushConnection, SignConfig } = require('tiktok-live-connector');

// Set your API key BEFORE creating the connection
SignConfig.apiKey = 'YOUR_API_KEY';

const connection = new WebcastPushConnection('@tv_asahi_news');

connection.connect().then(state => {
    console.log(`Connected to Room ${state.roomId}!`);
}).catch(err => {
    console.error('Connection failed:', err);
});

connection.on('chat', data => {
    console.log(`${data.uniqueId}: ${data.comment}`);
});
```

</Tab>
<Tab value="Java">

### 1. Add the dependency

```xml
<dependency>
    <groupId>io.github.jwdeveloper.tiktok</groupId>
    <artifactId>Client-Live</artifactId>
    <version>LATEST</version>
</dependency>
```

### 2. Connect to a livestream

```java
import io.github.jwdeveloper.tiktok.TikTokLive;

public class Main {
    public static void main(String[] args) {
        TikTokLive.newClient("@tv_asahi_news")
            .configure(settings -> {
                settings.setApiKey("YOUR_API_KEY");
            })
            .onConnected((liveClient, event) -> {
                System.out.println("Connected to Room " + event.getRoomInfo().getRoomId());
            })
            .onComment((liveClient, event) -> {
                System.out.println(event.getUser().getName() + ": " + event.getText());
            })
            .buildAndConnect();
    }
}
```

</Tab>
<Tab value="Go">

### 1. Install the library

```bash
go get github.com/steampoweredtaco/gotiktoklive
```

### 2. Connect to a livestream

```go
package main

import (
    "fmt"
    ttl "github.com/steampoweredtaco/gotiktoklive"
)

func main() {
    live, err := ttl.NewTikTok(
        ttl.SigningApiKey("YOUR_API_KEY"),
    )
    if err != nil {
        panic(err)
    }
    started, err := live.TrackUser("@tv_asahi_news")
    if err != nil {
        panic(err)
    }
    for event := range started.Events {
        switch e := event.(type) {
        case ttl.UserEvent:
            fmt.Printf("%s joined\n", e.User.Nickname)
        case ttl.ChatEvent:
            fmt.Printf("%s: %s\n", e.User.Nickname, e.Comment)
        }
    }
}
```

</Tab>
</Tabs>

<Callout type="info">
Replace `YOUR_API_KEY` with the API key from your dashboard. Replace `@tv_asahi_news` with any TikTok
username that is currently live.
</Callout>

## 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

<Cards>
<Card title="API Key Usage" href="/docs/api-key-usage/python">
Detailed setup guides for each language and library.
</Card>
<Card title="Rate Limits" href="/docs/api/rate-limits">
Understand your usage limits and how to increase them.
</Card>
<Card title="WebSocket Server" href="/docs/api/websockets">
Advanced WebSocket configuration and SDK usage.
</Card>
<Card title="TikTok Live API on GitHub" href="https://github.com/EulerStream/TikTok-Live-Api">
Open source REST SDKs for TypeScript, Python, C#, Java, and Go.
</Card>
</Cards>
