Game Dev Guide

Build a TikTok LIVE Interactive Game

Let viewers control your game with chat commands, gifts, and likes. Works with Unreal Engine, Unity, web browsers, and any WebSocket-capable engine.

tiktok.com/@
Stream offlineEnter a live TikTok username above
Connecting to @ live
Offline
Live Stream Monitor
@
<50msLatency
99.9%Uptime
FreeTo Test

What Are TikTok LIVE Games?

TikTok LIVE interactive games are viewer-controlled experiences where the audience's actions directly affect gameplay. When viewers send chat messages, gifts, likes, or follow the streamer, those events trigger in-game responses - spawning enemies, changing the environment, or controlling characters.

Popular examples include:

  • Chat-controlled battles - viewers type commands to join teams and fight
  • Gift-triggered effects - sending a Rose spawns an item, a Universe triggers a boss fight
  • Like floods - likes affect gravity, speed, or difficulty
  • Follow alerts - new followers spawn friendly NPCs

How It Works

Your game connects to the TikTool Live API via WebSocket and receives real-time events from the TikTok LIVE stream. Each event includes the viewer's username, the action they took, and relevant data (gift value, chat message, etc.).

// The flow:
// 1. Viewer watches TikTok LIVE stream
// 2. Viewer sends a gift/chat/like
// 3. TikTool API delivers the event via WebSocket
// 4. Your game receives the event and responds

TikTok LIVE → TikTool API → WebSocket → Your Game Engine

Option 1: Web Game (JavaScript)

The simplest approach - connect directly from a browser or Node.js backend:

import { TikTokLive } from '@tiktool/live'

const client = new TikTokLive({
  uniqueId: 'streamer_username',
  apiKey: process.env.TIKTOOL_API_KEY
})

// Gift → Spawn an item based on gift value
client.on('gift', (event) => {
  const item = event.diamondCount >= 100
    ? 'boss_enemy'
    : event.diamondCount >= 10
    ? 'power_up'
    : 'small_coin'

  spawnItem(item, event.nickname)
  console.log(`${event.nickname} spawned a ${item} with ${event.giftName}!`)
})

// Chat → Let viewers vote or issue commands
client.on('chat', (event) => {
  const cmd = event.comment.toLowerCase().trim()

  if (cmd === '!join') {
    addPlayer(event.nickname, event.userId)
  } else if (cmd === '!left' || cmd === '!right') {
    movePlayer(event.nickname, cmd.replace('!', ''))
  }
})

// Like → Increase game speed or difficulty
client.on('like', (event) => {
  increaseDifficulty(event.totalLikeCount)
})

// Viewer count → Scale the challenge
client.on('viewer_count', (event) => {
  setEnemySpawnRate(event.viewerCount / 100)
})

await client.connect()
console.log('🎮 Game connected to TikTok LIVE!')

Option 2: Unreal Engine (C++)

TikTool provides a native Unreal Engine plugin - TikToolLive - that connects to the API and delivers events via Blueprint-compatible delegates.

  • Download the plugin from GitHub
  • Place it in your project's Plugins/ directory
  • Enable in your .uproject file
// In your GameMode or Actor class:

#include "TikToolLiveSubsystem.h"

void AMyGameMode::BeginPlay()
{
    Super::BeginPlay();

    auto* Subsystem = GetGameInstance()->GetSubsystem<UTikToolLiveSubsystem>();

    // Listen for gifts
    Subsystem->OnGiftReceived.AddDynamic(this, &AMyGameMode::HandleGift);

    // Listen for chat
    Subsystem->OnChatReceived.AddDynamic(this, &AMyGameMode::HandleChat);

    // Connect to streamer
    Subsystem->Connect(TEXT("streamer_username"), TEXT("YOUR_API_KEY"));
}

void AMyGameMode::HandleGift(const FTikToolGiftEvent& Event)
{
    // Event.Nickname, Event.GiftName, Event.DiamondCount
    if (Event.DiamondCount >= 100)
    {
        SpawnBoss(Event.Nickname);
    }
}

void AMyGameMode::HandleChat(const FTikToolChatEvent& Event)
{
    // Event.Nickname, Event.Comment
    if (Event.Comment == TEXT("!join"))
    {
        AddPlayerToArena(Event.Nickname);
    }
}

In Blueprints, bind to the OnGiftReceived and OnChatReceived delegates from the TikToolLive Subsystem.

Option 3: Unity (C#)

Use the raw WebSocket connection from Unity - no additional plugin required:

using System;
using UnityEngine;
using NativeWebSocket;  // Install via Package Manager

public class TikTokLiveGame : MonoBehaviour
{
    WebSocket ws;

    async void Start()
    {
        ws = new WebSocket(
            "wss://api.tik.tools?uniqueId=streamer_username&apiKey=YOUR_API_KEY"
        );

        ws.OnMessage += (bytes) =>
        {
            var json = System.Text.Encoding.UTF8.GetString(bytes);
            var msg = JsonUtility.FromJson<TikToolEvent>(json);

            switch (msg.@event)
            {
                case "gift":
                    SpawnGiftEffect(msg.data.giftName, msg.data.diamondCount);
                    break;
                case "chat":
                    ProcessChatCommand(msg.data.comment, msg.data.user.nickname);
                    break;
                case "like":
                    IncreaseDifficulty();
                    break;
            }
        };

        await ws.Connect();
        Debug.Log("Connected to TikTok LIVE!");
    }

    void Update()
    {
        #if !UNITY_WEBGL || UNITY_EDITOR
        ws?.DispatchMessageQueue();
        #endif
    }
}

Game Design Tips

  • Show viewer names - display the gifter's or chatter's username in-game so viewers feel recognized
  • Scale with viewers - use viewer_count events to dynamically adjust difficulty
  • Gift tiers - map TikTok gift values (1💎 = small, 10💎 = medium, 100💎+ = epic) to in-game effects
  • Cooldowns - prevent spam by adding per-user cooldowns on chat commands
  • Visual feedback - always show what happened when a viewer interacts so the audience stays engaged

FAQ

Do I need TikTok's official API to make a LIVE game?

No. TikTok does not offer a public API for LIVE stream events. TikTool provides a managed third-party API with WebSocket delivery that works with any game engine. The free Sandbox tier is enough to prototype your game.

What events can I use in my game?

All events: chat, gift, like, follow, share, member (join), viewer_count. See the Events Reference for full documentation.

Can I use this with Godot, GameMaker, or other engines?

Yes. Any engine that supports WebSocket connections can use the TikTool API. Connect to wss://api.tik.tools and parse the JSON messages. No SDK required.