🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

github.com/tserkov/go-twitch-api

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/tserkov/go-twitch-api

v0.0.0-20180208075407-03e7ebbcd6a4
Source
Go
Version published
Created
Source

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.

FAQs

Package last updated on 08 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts