Open Source Libraries

Go

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

|View as Markdown|

GoTikTokLive is a Go library for connecting to TikTok LIVE streams. It uses a channel-based API for receiving events.

View the full source on GitHub.

Quickstart

1

Install the package

go get github.com/steampoweredtaco/gotiktoklive
2

Configure your API key

import "github.com/steampoweredtaco/gotiktoklive"

tiktok := gotiktoklive.NewTikTok()
tiktok.SetSigningApiKey("YOUR_API_KEY")
3

Connect and listen to events

live, err := tiktok.TrackUser("username")
if err != nil {
    panic(err)
}

for event := range live.Events {
    switch e := event.(type) {
    case gotiktoklive.ChatEvent:
        fmt.Printf("%s: %s\n", e.User.Username, e.Comment)
    case gotiktoklive.GiftEvent:
        fmt.Printf("%s sent a gift!\n", e.User.Username)
    case gotiktoklive.ViewersEvent:
        fmt.Printf("Viewers: %d\n", e.Viewers)
    default:
        fmt.Printf("%T: %+v\n", e, e)
    }
}

Stream Download

GoTikTokLive can also download the live stream video (requires ffmpeg):

if err := live.DownloadStream(); err != nil {
    panic(err)
}

See the API Key Usage guide for more configuration options.