helix

package
v0.2.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2021 License: BSD-3-Clause, GPL-3.0, ISC Imports: 11 Imported by: 0

Documentation

Overview

Package helix provides a HTTP client to communicate with the Twitch Helix API endpoints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveExtension

type ActiveExtension struct {
	Active  bool   `json:"active"`
	ID      string `json:"id,omitempty"`
	Name    string `json:"name,omitempty"`
	Version string `json:"version,omitempty"`
	X       int    `json:"x,omitempty"`
	Y       int    `json:"y,omitempty"`
}

ActiveExtension represents a currently active extension.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client handles communication with the Twitch Helix API.

func NewClient

func NewClient(cfg *Config) (*Client, error)

NewClient returns a new Helix Client depending on options provided by cfg. If the Token field of the config is nil, the client will attempt create an app access token using the 2-legged OAuth2 client credentials flow. If a Token is provided, the client will attempt to use the token as a user access token.

func (*Client) GetClips

func (client *Client) GetClips(opt *GetClipsOpt) (*GetClipsResponse, error)

GetClips gets information by clip id, broadcaster id or game id.

https://dev.twitch.tv/docs/api/reference/#get-clips

func (*Client) GetGames added in v0.2.5

func (client *Client) GetGames(opt *GetGamesOpt) (*GetGamesResponse, error)

GetGames gets information by game name or game id

https://dev.twitch.tv/docs/api/reference/#get-games

func (*Client) GetModerators added in v0.2.3

func (client *Client) GetModerators(opt *GetModsOpt) (*GetModsResponse, error)

GetModerators returns information about a Twitch channel's mods. Returns a GetModsResponse constructed from the response from the API endpoint.

https://dev.twitch.tv/docs/api/reference#get-moderators

func (*Client) GetStreams

func (client *Client) GetStreams(opt *GetStreamsOpt) (*GetStreamsResponse, error)

GetStreams returns a slice representing the top active streams sorted by viewcount. Also returns a Pagination field used to query for more streams

https://dev.twitch.tv/docs/api/reference#get-streams

func (*Client) GetUserActiveExtensions

func (client *Client) GetUserActiveExtensions(opt *GetUserActiveExtensionsOpt) (*GetUserActiveExtensionsResponse, error)

GetUserActiveExtensions returns information about active and inactive extensions for a user identified by the user token Requires scope user:read:broadcast or user:edit:broadcast

https://dev.twitch.tv/docs/api/reference#get-user-active-extensions

func (*Client) GetUserExtensions

func (client *Client) GetUserExtensions() (*GetUserExtensionsResponse, error)

GetUserExtensions returns information about active and inactive extensions for a user identified by the user token. Requires scope user:read:broadcast

https://dev.twitch.tv/docs/api/reference#get-users-follows

func (*Client) GetUsers

func (client *Client) GetUsers(opt *GetUsersOpt) (*GetUsersResponse, error)

GetUsers returns information about a Twitch user. Returns a GetUsersResponse constructed from the response from the API endpoint.

https://dev.twitch.tv/docs/api/reference#get-users

func (*Client) GetUsersFollows

func (client *Client) GetUsersFollows(opt *GetUsersFollowsOpt) (*GetUsersFollowsResponse, error)

GetUsersFollows obtains information about who a user is following or who follows a user. Returns a GetUsersFollowsResponse constructed from the response from the API endpoint.

https://dev.twitch.tv/docs/api/reference#get-users-follows

func (*Client) GetVideos added in v0.2.7

func (client *Client) GetVideos(opt *GetVideosOpt) (*GetVideosResponse, error)

GetVideos gets information by vodep id, user id or game id.

https://dev.twitch.tv/docs/api/reference/#get-videos

func (*Client) UpdateUser

func (client *Client) UpdateUser(opt *UpdateUserOpt) (*GetUsersResponse, error)

UpdateUser updates the description of a user. Requires a user token for the user to be updated. Returns a GetUsersResponse constructed from the response from the API endpoint. Requires scope: user:edit

https://dev.twitch.tv/docs/api/reference#update-user

type Config

type Config struct {
	ClientID     string
	ClientSecret string
	Scopes       []string
	RedirectURI  string
	Token        *oauth2.Token
}

Config represents configuration options available to a Client.

type GetClipsData

type GetClipsData struct {
	ID              string `json:"id,omitempty"`
	URL             string `json:"url,omitempty"`
	EmbedURL        string `json:"embed_url,omitempty"`
	BroadcasterID   string `json:"broadcaster_id,omitempty"`
	BroadcasterName string `json:"broadcaster_name,omitempty"`
	CreatorID       string `json:"creator_id,omitempty"`
	CreatorName     string `json:"creator_name,omitempty"`
	VideoID         string `json:"video_id,omitempty"`
	GameID          string `json:"game_id,omitempty"`
	Language        string `json:"language,omitempty"`
	Title           string `json:"title,omitempty"`
	ViewCount       int    `json:"view_count,omitempty"`
	CreatedAt       string `json:"created_at,omitempty"`
	ThumbnailURL    string `json:"thumbnail_url,omitempty"`
}

GetClipsData represents metadata about a clip.

type GetClipsOpt

type GetClipsOpt struct {
	ID            string `url:"id,omitempty"`
	BroadcasterID string `url:"broadcaster_id,omitempty"`
	GameID        string `url:"game_id,omitempty"`
	After         string `url:"after,omitempty"`
	First         int    `url:"first,omitempty"`
	StartedAt     string `url:"started_at,omitempty"`
	EndedAt       string `url:"ended_at,omitempty"`
}

GetClipsOpt defines the options available for Get Clips.

type GetClipsResponse

type GetClipsResponse struct {
	Data       []GetClipsData `json:"data,omitempty"`
	Pagination PaginationData
}

GetClipsResponse represents the response from a Get Clips command.

type GetGamesData added in v0.2.5

type GetGamesData struct {
	BoxArtURL string `json:"box_art_url,omitempty"`
	ID        string `json:"id,omitempty"`
	Name      string `json:"name,omitempty"`
}

GetGamesData represents metadata about a game.

type GetGamesOpt added in v0.2.5

type GetGamesOpt struct {
	ID   string `url:"id,omitempty"`
	Name string `url:"name,omitempty"`
}

GetGamesOpt defines the options available for Get Games.

type GetGamesResponse added in v0.2.5

type GetGamesResponse struct {
	Data       []GetGamesData `json:"data,omitempty"`
	Pagination PaginationData
}

GetGamesResponse represents the response from a Get Games command.

type GetModsData added in v0.2.3

type GetModsData struct {
	UserId   string `json:"user_id,omitempty"`
	UserName string `json:"user_name,omitempty"`
}

GetModsData represents information moderators of a channel.

type GetModsOpt added in v0.2.3

type GetModsOpt struct {
	BroadcasterId string `url:"broadcaster_id,omitempty"`
	UserId        string `url:"user_id,omitempty"`
	After         string `url:"after,omitempty"`
}

GetModsOpt defines the options available for Get Moderators.

type GetModsResponse added in v0.2.3

type GetModsResponse struct {
	Data       []GetModsData  `json:"data,omitempty"`
	Pagination PaginationData `json:"pagination,omitempty"`
}

GetModsResponse represents a response from a Get Users command

type GetStreamsOpt

type GetStreamsOpt struct {
	After     string `url:"after,omitempty"`
	Before    string `url:"before,omitempty"`
	First     int    `url:"first,omitempty"`
	GameID    string `url:"game_id,omitempty"`
	Language  string `url:"language,omitempty"`
	UserID    string `url:"user_id,omitempty"`
	UserLogin string `url:"user_login,omitempty"`
}

GetStreamsOpt defines the options available for Get Streams.

type GetStreamsResponse

type GetStreamsResponse struct {
	Data []struct {
		GameID       string   `json:"game_id,omitempty"`
		ID           string   `json:"id,omitempty"`
		Language     string   `json:"language,omitempty"`
		StartedAt    string   `json:"started_at,omitempty"`
		ThumbnailURL string   `json:"thumbnail_url,omitempty"`
		Title        string   `json:"title,omitempty"`
		Type         string   `json:"type,omitempty"`
		UserID       string   `json:"user_id,omitempty"`
		Username     string   `json:"user_name,omitempty"`
		ViewerCount  int      `json:"viewer_count,omitempty"`
		TagIDs       []string `json:"tag_ids,omitempty"`
	} `json:"data,omitempty"`

	Pagination struct {
		Cursor string `json:"cursor,omitempty"`
	} `json:"pagination,omitempty"`
}

GetStreamsResponse represents a response from a Get Streams command.

type GetUserActiveExtensionsData

type GetUserActiveExtensionsData struct {
	Component map[string]ActiveExtension `json:"component,omitempty"`
	Overlay   map[string]ActiveExtension `json:"overlay,omitempty"`
	Panel     map[string]ActiveExtension `json:"panel,omitempty"`
}

GetUserActiveExtensionsData represents information about a users active extensions.

type GetUserActiveExtensionsOpt

type GetUserActiveExtensionsOpt struct {
	UserID string `url:"user_id"`
}

GetUserActiveExtensionsOpt defines the options available for Get User Active Extensions

type GetUserActiveExtensionsResponse

type GetUserActiveExtensionsResponse struct {
	Data GetUserActiveExtensionsData `json:"data,omitempty"`
}

GetUserActiveExtensionsResponse represents a response from a Get Users Extensions command

type GetUserExtensionsResponse

type GetUserExtensionsResponse struct {
	Data []GetUsersExtensionsData `json:"data,omitempty"`
}

GetUserExtensionsResponse represents a response from a Get Users Extensions command

type GetUsersData

type GetUsersData struct {
	ID              string `json:"id,omitempty"`
	Login           string `json:"login,omitempty"`
	DisplayName     string `json:"display_name,omitempty"`
	Type            string `json:"type,omitempty"`
	BroadcasterType string `json:"broadcaster_type,omitempty"`
	Description     string `json:"description,omitempty"`
	ProfileImageURL string `json:"profile_image_url,omitempty"`
	OfflineImageURL string `json:"offline_image_url,omitempty"`
	ViewCount       int    `json:"view_count,omitempty"`
	Email           string `json:"email,omitempty"`
}

GetUsersData represents information about a user.

type GetUsersExtensionsData

type GetUsersExtensionsData struct {
	ID          string   `json:"id,omitempty"`
	Version     string   `json:"version,omitempty"`
	Name        string   `json:"name,omitempty"`
	CanActivate bool     `json:"can_activate,omitempty"`
	Type        []string `json:"type,omitempty"`
}

GetUsersExtensionsData represents information about a users extensions.

type GetUsersFollowsData

type GetUsersFollowsData struct {
	FollowedAt time.Time `json:"followed_at,omitempty"`
	FromID     string    `json:"from_id,omitempty"`
	FromName   string    `json:"from_name,omitempty"`
	ToID       string    `json:"to_id,omitempty"`
	ToName     string    `json:"to_name,omitempty"`
}

GetUsersFollowsData represents information about a user follow.

type GetUsersFollowsOpt

type GetUsersFollowsOpt struct {
	After  string `url:"after,omitempty"`
	First  int    `url:"first,omitempty"`
	FromID string `url:"from_id,omitempty"`
	ToID   string `url:"to_id,omitempty"`
}

GetUsersFollowsOpt defines the options available for Get Users Follows.

type GetUsersFollowsResponse

type GetUsersFollowsResponse struct {
	Total      int                   `json:"total,omitempty"`
	Data       []GetUsersFollowsData `json:"data,omitempty"`
	Pagination PaginationData        `json:"pagination,omitempty"`
}

GetUsersFollowsResponse represents a response from a Get Users Follows command

type GetUsersOpt

type GetUsersOpt struct {
	ID    []string `url:"id,omitempty"`
	Login []string `url:"login,omitempty"`
}

GetUsersOpt defines the options available for Get Users.

type GetUsersResponse

type GetUsersResponse struct {
	Data []GetUsersData `json:"data,omitempty"`
}

GetUsersResponse represents a response from a Get Users command

type GetVideosData added in v0.2.7

type GetVideosData struct {
	CreatedAt    string `json:"created_at,omitempty"`
	Description  string `json:"description,omitempty"`
	Duration     string `json:"duration,omitempty"`
	ID           string `json:"id,omitempty"`
	Language     string `json:"language,omitempty"`
	PublishedAt  string `json:"published_at,omitempty"`
	ThumbnailURL string `json:"thumbnail_url,omitempty"`
	Title        string `json:"title,omitempty"`
	Type         string `json:"type,omitempty"`
	URL          string `json:"url,omitempty"`
	UserID       string `json:"user_id,omitempty"`
	UserName     string `json:"user_name,omitempty"`
	ViewCount    int    `json:"view_count,omitempty"`
	Viewable     string `json:"viewable,omitempty"`
}

GetVideosData represents metadata about a video.

type GetVideosOpt added in v0.2.7

type GetVideosOpt struct {
	ID       string `url:"id,omitempty"`
	UserID   string `url:"user_id,omitempty"`
	GameID   string `url:"game_id,omitempty"`
	After    string `url:"after,omitempty"`
	Before   string `url:"before,omitempty"`
	First    string `url:"first,omitempty"`
	Language string `url:"language,omitempty"`
	Period   string `url:"period,omitempty"`
	Sort     string `url:"sort,omitempty"`
	Type     string `url:"type,omitempty"`
}

GetVideosOpt defines the options available for Get Videos.

type GetVideosResponse added in v0.2.7

type GetVideosResponse struct {
	Data       []GetVideosData `json:"data,omitempty"`
	Pagination PaginationData
}

GetVideosResponse represents the response from a Get Videos command.

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient interface for mocking purposes

type PaginationData

type PaginationData struct {
	Cursor string `json:"cursor,omitempty"`
}

PaginationData represents the current ID for a multi-page response.

type Response

type Response struct {
	Status int
	Header http.Header
	Data   []byte
}

Response represents an HTTP response with un-decoded body bytes.

type UpdateUserOpt

type UpdateUserOpt struct {
	Description string `url:"description"`
}

UpdateUserOpt defines the options available for Update User

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL