Connect to any TikTok Live stream and receive real-time events in Python. No signing server, no API keys, no authentication required.
import asyncio
from piratetok_live import TikTokLiveClient, EventType
async def main():
# Create client — no API key, no signing server, just a username
client = TikTokLiveClient("username_here")
# Register handlers with decorators — events carry decoded protobuf data
@client.on(EventType.chat)
def on_chat(evt):
nick = evt.data.get("user", {}).get("nickname", "?")
print(f"[chat] {nick}: {evt.data.get('content')}")
@client.on(EventType.gift)
def on_gift(evt):
nick = evt.data.get("user", {}).get("nickname", "?")
gift = evt.data.get("gift", {})
print(f"[gift] {nick} sent {gift.get('name')} x{evt.data.get('repeatCount')} ({gift.get('diamondCount', 0)} diamonds)")
@client.on(EventType.like)
def on_like(evt):
nick = evt.data.get("user", {}).get("nickname", "?")
print(f"[like] {nick} ({evt.data.get('totalLikes')} total)")
# Connect — handles auth, room resolution, WSS, heartbeat, and reconnection
await client.connect()
asyncio.run(main())pip install piratetok-live
Requires Python >= 3.11.
| Language | Install | Repo |
|---|---|---|
| Rust | cargo add piratetok-live-rs |
live-rs |
| Go | go get github.com/PirateTok/live-go |
live-go |
| JavaScript | npm install piratetok-live-js |
live-js |
| C# | dotnet add package PirateTok.Live |
live-cs |
| Java | com.piratetok:live |
live-java |
| Lua | luarocks install piratetok-live-lua |
live-lua |
| Elixir | {:piratetok_live, "~> 0.1"} |
live-ex |
| Dart | dart pub add piratetok_live |
live-dart |
| C | #include "piratetok.h" |
live-c |
| PowerShell | Install-Module PirateTok.Live |
live-ps1 |
| Shell | bpkg install PirateTok/live-sh |
live-sh |
- Zero signing dependency — no API keys, no signing server, no external auth
- 64 decoded event types — hand-written betterproto dataclasses, no codegen
- Auto-reconnection — stale detection, exponential backoff, self-healing auth
- Proxy support —
.proxy(url)builder, applies to HTTP + WSS - Enriched User data — badges, gifter level, moderator status, follow info, fan club
- Sub-routed convenience events —
follow,share,join,liveEnded - 2 runtime deps —
betterproto+websockets
client = (TikTokLiveClient("username_here")
.cdn_eu()
.timeout(15)
.max_retries(10)
.stale_timeout(90)
.proxy("socks5://127.0.0.1:1080"))from piratetok_live import check_online, fetch_room_info
result = check_online("username_here")
info = fetch_room_info(result.room_id)
# 18+ rooms
info = fetch_room_info(result.room_id, cookies="sessionid=abc; sid_tt=abc")python examples/basic_chat.py <username> # connect + print chat events
python examples/online_check.py <username> # check if user is live
python examples/stream_info.py <username> # fetch room metadata + stream URLs
python examples/gift_tracker.py <username> # track gifts with diamond totals0BSD
