Skip to content

Latest commit

 

History

History
executable file
·
65 lines (49 loc) · 1.93 KB

README.md

File metadata and controls

executable file
·
65 lines (49 loc) · 1.93 KB

Twitch API (Golang)

Travis GitHub issues Coveralls license Beerpay

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.

Usage

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)
}

Users

  • 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.

Todo

  • Channels endpoints
  • Chat endpoints
  • Games endpoints
  • Ingests endpoints
  • Search endpoints
  • Streams endpoints
  • Teams endpoints
  • Users endpoints
  • Videos endpoints

Yea... all the endpoints.