This is a Go wrapper for the Twitch.tv Kraken API, initially created for an internal project, but am making public as I build it out to our requirements.
package main
import (
"fmt"
"github.com/tserkov/go-twitch-api"
)
func main() {
t := twitch.NewClient("CLIENT_ID", "CLIENT_SECRET", "CLIENT_REDIRECT")
u, err := t.Users.GetByLogin("tserkov")
if err != nil {
fmt.Printf("Failed to get users: %s", err)
return
}
if u.Total == 0 {
fmt.Printf("No users found with login/username tserkov")
return
}
tserkov := u.Users[0]
fmt.Printf("User ID for %s is %s", tserkov.DisplayName, tserkov.Id)
}
- GetAccessToken (authorizationCode string) string
- Exchanges an authorization code (which you somehow obtained from Twitch's OAuth flow) for an access token.
- GetAuthenticated (accessToken string) twitch.User, error
- Gets the user associated with the provided access token.
- GetByLogin (username string) twitch.Users, error
- Returns users matching the provided username/login. Useful for converting username/login to user id.
- GetFollowedChannelInfo (followerId string, channelId string) twitch.Follows, error
- If the provided user id is following the provided channel id, returns the related follow info.
- Channels endpoints
- Chat endpoints
- Games endpoints
- Ingests endpoints
- Search endpoints
- Streams endpoints
- Teams endpoints
- Users endpoints
- Videos endpoints
Yea... all the endpoints.