Documentation ¶
Index ¶
- Constants
- Variables
- func GetWebhookTopicValuesFromRequest(req *http.Request, topic WebhookTopic) map[string]string
- type AccessCredentials
- type AppAccessTokenResponse
- type AuthorizationURLParams
- type Ban
- type BannedUsersParams
- type BannedUsersResponse
- type BitsLeaderboardParams
- type BitsLeaderboardResponse
- type Channel
- type Client
- func (c *Client) CreateClip(params *CreateClipParams) (*CreateClipResponse, error)
- func (c *Client) CreateEntitlementsUploadURL(manifestID, entitlementType string) (*EntitlementsUploadResponse, error)
- func (c *Client) CreateStreamMarker(params *CreateStreamMarkerParams) (*CreateStreamMarkerResponse, error)
- func (c *Client) GetAppAccessToken(scopes []string) (*AppAccessTokenResponse, error)
- func (c *Client) GetAuthorizationURL(params *AuthorizationURLParams) string
- func (c *Client) GetBannedUsers(params *BannedUsersParams) (*BannedUsersResponse, error)
- func (c *Client) GetBitsLeaderboard(params *BitsLeaderboardParams) (*BitsLeaderboardResponse, error)
- func (c *Client) GetClips(params *ClipsParams) (*ClipsResponse, error)
- func (c *Client) GetExtensionAnalytics(params *ExtensionAnalyticsParams) (*ExtensionAnalyticsResponse, error)
- func (c *Client) GetGameAnalytics(params *GameAnalyticsParams) (*GameAnalyticsResponse, error)
- func (c *Client) GetGames(params *GamesParams) (*GamesResponse, error)
- func (c *Client) GetStreamMarkers(params *StreamMarkersParams) (*StreamMarkersResponse, error)
- func (c *Client) GetStreams(params *StreamsParams) (*StreamsResponse, error)
- func (c *Client) GetStreamsMetadata(params *StreamsMetadataParams) (*StreamsMetadataResponse, error)
- func (c *Client) GetSubscriptions(params *SubscriptionsParams) (*SubscriptionsResponse, error)
- func (c *Client) GetTopGames(params *TopGamesParams) (*TopGamesResponse, error)
- func (c *Client) GetUserAccessToken(code string) (*UserAccessTokenResponse, error)
- func (c *Client) GetUserActiveExtensions(params *UserActiveExtensionsParams) (*UserActiveExtensionsResponse, error)
- func (c *Client) GetUserExtensions() (*UserExtensionsResponse, error)
- func (c *Client) GetUsers(params *UsersParams) (*UsersResponse, error)
- func (c *Client) GetUsersFollows(params *UsersFollowsParams) (*UsersFollowsResponse, error)
- func (c *Client) GetVideos(params *VideosParams) (*VideosResponse, error)
- func (c *Client) GetWebhookSubscriptions(params *WebhookSubscriptionsParams) (*WebhookSubscriptionsResponse, error)
- func (c *Client) PostWebhookSubscription(payload *WebhookSubscriptionPayload) (*WebhookSubscriptionResponse, error)
- func (c *Client) RefreshUserAccessToken(refreshToken string) (*RefreshTokenResponse, error)
- func (c *Client) RevokeUserAccessToken(accessToken string) (*RevokeAccessTokenResponse, error)
- func (c *Client) SearchChannels(params *SearchChannelsParams) (*SearchChannelsResponse, error)
- func (c *Client) SetAppAccessToken(accessToken string)
- func (c *Client) SetRedirectURI(uri string)
- func (c *Client) SetUserAccessToken(accessToken string)
- func (c *Client) SetUserAgent(userAgent string)
- func (c *Client) UpdateUser(params *UpdateUserParams) (*UsersResponse, error)
- func (c *Client) UpdateUserExtensions(payload *UpdateUserExtensionsPayload) (*UserActiveExtensionsResponse, error)
- func (c *Client) ValidateToken(accessToken string) (bool, *ValidateTokenResponse, error)
- type Clip
- type ClipEditURL
- type ClipsParams
- type ClipsResponse
- type CreateClipParams
- type CreateClipResponse
- type CreateStreamMarker
- type CreateStreamMarkerParams
- type CreateStreamMarkerResponse
- type DateRange
- type EntitlementsUploadResponse
- type EntitlementsUploadURL
- type ExtensionAnalytic
- type ExtensionAnalyticsParams
- type ExtensionAnalyticsResponse
- type Game
- type GameAnalytic
- type GameAnalyticsParams
- type GameAnalyticsResponse
- type GamesParams
- type GamesResponse
- type HTTPClient
- type HearthstoneHero
- type HearthstoneMetadata
- type HearthstonePlayerData
- type ManyBans
- type ManyClipEditURLs
- type ManyClips
- type ManyCreateStreamMarkers
- type ManyEntitlementsUploadURLs
- type ManyExtensionAnalytics
- type ManyFollows
- type ManyGameAnalytics
- type ManyGames
- type ManyGamesWithPagination
- type ManySearchChannels
- type ManyStreamMarkers
- type ManyStreams
- type ManyStreamsMetadata
- type ManySubscriptions
- type ManyUserBitTotals
- type ManyUserExtensions
- type ManyUsers
- type ManyVideos
- type ManyWebhookSubscriptions
- type Marker
- type Options
- type OverwatchBroadcaster
- type OverwatchHero
- type OverwatchMetadata
- type Pagination
- type RateLimitFunc
- type RefreshTokenResponse
- type Response
- type ResponseCommon
- type RevokeAccessTokenResponse
- type SearchChannelsParams
- type SearchChannelsResponse
- type Stream
- type StreamMarker
- type StreamMarkersParams
- type StreamMarkersResponse
- type StreamMetadata
- type StreamsMetadataParams
- type StreamsMetadataResponse
- type StreamsParams
- type StreamsResponse
- type Subscription
- type SubscriptionsParams
- type SubscriptionsResponse
- type Time
- type TopGamesParams
- type TopGamesResponse
- type UpdateUserExtensionsPayload
- type UpdateUserParams
- type User
- type UserAccessTokenResponse
- type UserActiveExtension
- type UserActiveExtensionInfo
- type UserActiveExtensionSet
- type UserActiveExtensionsParams
- type UserActiveExtensionsResponse
- type UserBitTotal
- type UserExtension
- type UserExtensionsResponse
- type UserFollow
- type UsersFollowsParams
- type UsersFollowsResponse
- type UsersParams
- type UsersResponse
- type ValidateTokenResponse
- type Video
- type VideoMarker
- type VideosParams
- type VideosResponse
- type WebhookSubscription
- type WebhookSubscriptionPayload
- type WebhookSubscriptionResponse
- type WebhookSubscriptionsParams
- type WebhookSubscriptionsResponse
- type WebhookTopic
Constants ¶
const ( // DefaultAPIBaseURL is the base URL for composing API requests. DefaultAPIBaseURL = "https://api.twitch.tv/helix" // AuthBaseURL is the base URL for composing authentication requests. AuthBaseURL = "https://id.twitch.tv/oauth2" )
Variables ¶
var ( UserFollowsRegexp = regexp.MustCompile("helix/users/follows\\?first=1(&from_id=(?P<from_id>\\d+))?(&to_id=(?P<to_id>\\d+))?>") StreamChangedRegexp = regexp.MustCompile("helix/streams\\?user_id=(?P<user_id>\\d+)>") UserChangedRegexp = regexp.MustCompile("helix/users\\?id=(?P<id>\\d+)>") GameAnalyticsRegexp = regexp.MustCompile("helix/analytics\\?game_id=(?P<game_id>\\w+)>") ExtensionAnalyticsRegexp = regexp.MustCompile("helix/analytics\\?extension_id=(?P<extension_id>\\w+)>") )
Regular expressions used for parsing webhook link headers
Functions ¶
func GetWebhookTopicValuesFromRequest ¶ added in v0.4.2
func GetWebhookTopicValuesFromRequest(req *http.Request, topic WebhookTopic) map[string]string
GetWebhookTopicValuesFromRequest inspects the "Link" request header to determine if it matches against any recognised webhooks topics and returns the unique values specified in the header.
For example, say we receive a "User Follows" webhook event from Twitch. Its "Link" header value look likes the following:
<https://api.twitch.tv/helix/webhooks/hub>; rel="hub", <https://api.twitch.tv/helix/users/follows?first=1&from_id=111116&to_id=22222>; rel="self"
From which GetWebhookTopicValuesFromRequest will return a map with the values of from_id and to_id:
map[from_id:111116 to_id:22222]
This is particularly useful for webhooks events that do not have a distinguishable JSON payload, such as the "Stream Changed" down event.
Additionally, if topic is not known you can pass -1 as its value and
Types ¶
type AccessCredentials ¶ added in v0.7.0
type AccessCredentials struct { AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` ExpiresIn int `json:"expires_in"` Scopes []string `json:"scope"` }
AccessCredentials ...
type AppAccessTokenResponse ¶
type AppAccessTokenResponse struct { ResponseCommon Data AccessCredentials }
AppAccessTokenResponse ...
type AuthorizationURLParams ¶ added in v0.7.0
type AuthorizationURLParams struct { ResponseType string // (Required) Options: "code" or "token" Scopes []string // (Required) State string // (Optional) ForceVerify bool // (Optional) }
AuthorizationURLParams ...
type Ban ¶ added in v0.5.5
type Ban struct { UserID string `json:"user_id"` UserName string `json:"user_name"` ExpiresAt Time `json:"expires_at"` }
Ban ... ExpiresAt must be parsed manually since an empty string means perma ban
type BannedUsersParams ¶ added in v0.5.5
type BannedUsersParams struct { BroadcasterID string `query:"broadcaster_id"` UserID string `query:"user_id"` After string `query:"after"` Before string `query:"before"` }
BannedUsersResponse BroadcasterID must match the auth tokens user_id
type BannedUsersResponse ¶ added in v0.5.5
type BannedUsersResponse struct { ResponseCommon Data ManyBans }
BannedUsersResponse ...
type BitsLeaderboardParams ¶
type BitsLeaderboardParams struct { Count int `query:"count,10"` // Maximum 100 Period string `query:"period,all"` // "all" (default), "day", "week", "month" and "year" StartedAt time.Time `query:"started_at"` UserID string `query:"user_id"` }
BitsLeaderboardParams ...
type BitsLeaderboardResponse ¶
type BitsLeaderboardResponse struct { ResponseCommon Data ManyUserBitTotals }
BitsLeaderboardResponse ...
type Channel ¶ added in v0.6.0
type Channel struct { ID string `json:"id"` GameID string `json:"game_id"` DisplayName string `json:"display_name"` Language string `json:"broadcaster_language"` Title string `json:"title"` ThumbnailURL string `json:"thumbnail_url"` IsLive bool `json:"is_live"` StartedAt Time `json:"started_at"` TagIDs []string `json:"tag_ids"` }
Channel describes a channel from SearchChannel
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client ...
func NewClient ¶
NewClient returns a new Twicth Helix API client. It returns an if clientID is an empty string. It is concurrecy safe.
func (*Client) CreateClip ¶
func (c *Client) CreateClip(params *CreateClipParams) (*CreateClipResponse, error)
CreateClip creates a clip programmatically. This returns both an ID and an edit URL for the new clip. Clip creation takes time. We recommend that you query Get Clip, with the clip ID that is returned here. If Get Clip returns a valid clip, your clip creation was successful. If, after 15 seconds, you still have not gotten back a valid clip from Get Clip, assume that the clip was not created and retry Create Clip.
Required scope: clips:edit
func (*Client) CreateEntitlementsUploadURL ¶
func (c *Client) CreateEntitlementsUploadURL(manifestID, entitlementType string) (*EntitlementsUploadResponse, error)
CreateEntitlementsUploadURL return a URL where you can upload a manifest file and notify users that they have an entitlement. Entitlements are digital items that users are entitled to use. Twitch entitlements are granted to users gratis or as part of a purchase on Twitch.
func (*Client) CreateStreamMarker ¶ added in v0.4.2
func (c *Client) CreateStreamMarker(params *CreateStreamMarkerParams) (*CreateStreamMarkerResponse, error)
CreateStreamMarker creates a stream marker for a live stream at the current time. The user has to be the stream owner or an editor. Stream markers cannot be created in some cases, see: https://dev.twitch.tv/docs/api/reference/#create-stream-marker
Required Scope: user:edit:broadcast
func (*Client) GetAppAccessToken ¶
func (c *Client) GetAppAccessToken(scopes []string) (*AppAccessTokenResponse, error)
GetAppAccessToken ...
func (*Client) GetAuthorizationURL ¶
func (c *Client) GetAuthorizationURL(params *AuthorizationURLParams) string
GetAuthorizationURL ...
func (*Client) GetBannedUsers ¶ added in v0.5.5
func (c *Client) GetBannedUsers(params *BannedUsersParams) (*BannedUsersResponse, error)
GetBannedUsers returns all banned and timed-out users in a channel.
Required scope: moderation:read
func (*Client) GetBitsLeaderboard ¶
func (c *Client) GetBitsLeaderboard(params *BitsLeaderboardParams) (*BitsLeaderboardResponse, error)
GetBitsLeaderboard gets a ranked list of Bits leaderboard information for an authorized broadcaster.
Required Scope: bits:read
func (*Client) GetClips ¶
func (c *Client) GetClips(params *ClipsParams) (*ClipsResponse, error)
GetClips returns information about a specified clip.
func (*Client) GetExtensionAnalytics ¶ added in v0.4.0
func (c *Client) GetExtensionAnalytics(params *ExtensionAnalyticsParams) (*ExtensionAnalyticsResponse, error)
GetExtensionAnalytics returns a URL to the downloadable CSV file containing analytics data. Valid for 5 minutes.
func (*Client) GetGameAnalytics ¶
func (c *Client) GetGameAnalytics(params *GameAnalyticsParams) (*GameAnalyticsResponse, error)
GetGameAnalytics returns a URL to the downloadable CSV file containing analytics data for the specified game. Valid for 5 minutes.
func (*Client) GetGames ¶
func (c *Client) GetGames(params *GamesParams) (*GamesResponse, error)
GetGames ...
func (*Client) GetStreamMarkers ¶ added in v0.4.1
func (c *Client) GetStreamMarkers(params *StreamMarkersParams) (*StreamMarkersResponse, error)
GetStreamMarkers gets stream markers of a VOD or of the current live stream of an user being recorded as VOD.
Required Scope: user:read:broadcast
func (*Client) GetStreams ¶
func (c *Client) GetStreams(params *StreamsParams) (*StreamsResponse, error)
GetStreams returns a list of live channels based on the search parameters. To query offline channels, use SearchChannels.
func (*Client) GetStreamsMetadata ¶
func (c *Client) GetStreamsMetadata(params *StreamsMetadataParams) (*StreamsMetadataResponse, error)
GetStreamsMetadata ...
func (*Client) GetSubscriptions ¶ added in v0.5.3
func (c *Client) GetSubscriptions(params *SubscriptionsParams) (*SubscriptionsResponse, error)
GetSubscriptions gets subscriptions about one Twitch broadcaster. Broadcasters can only request their own subscriptions.
Required scope: channel:read:subscriptions
func (*Client) GetTopGames ¶
func (c *Client) GetTopGames(params *TopGamesParams) (*TopGamesResponse, error)
GetTopGames ...
func (*Client) GetUserAccessToken ¶
func (c *Client) GetUserAccessToken(code string) (*UserAccessTokenResponse, error)
GetUserAccessToken ...
func (*Client) GetUserActiveExtensions ¶ added in v0.5.6
func (c *Client) GetUserActiveExtensions(params *UserActiveExtensionsParams) (*UserActiveExtensionsResponse, error)
GetUserActiveExtensions Gets information about active extensions installed by a specified user, identified by a user ID or Bearer token.
Optional scope: user:read:broadcast or user:edit:broadcast
func (*Client) GetUserExtensions ¶ added in v0.5.6
func (c *Client) GetUserExtensions() (*UserExtensionsResponse, error)
GetUserExtensions gets a list of all extensions (both active and inactive) for a specified user, identified by a Bearer token
Required scope: user:read:broadcast
func (*Client) GetUsers ¶
func (c *Client) GetUsers(params *UsersParams) (*UsersResponse, error)
GetUsers gets information about one or more specified Twitch users. Users are identified by optional user IDs and/or login name. If neither a user ID nor a login name is specified, the user is looked up by Bearer token.
Optional scope: user:read:email
func (*Client) GetUsersFollows ¶
func (c *Client) GetUsersFollows(params *UsersFollowsParams) (*UsersFollowsResponse, error)
GetUsersFollows gets information on follow relationships between two Twitch users. Information returned is sorted in order, most recent follow first. This can return information like “who is lirik following,” “who is following lirik,” or “is user X following user Y.”
func (*Client) GetVideos ¶
func (c *Client) GetVideos(params *VideosParams) (*VideosResponse, error)
GetVideos gets video information by video ID (one or more), user ID (one only), or game ID (one only).
func (*Client) GetWebhookSubscriptions ¶ added in v0.3.1
func (c *Client) GetWebhookSubscriptions(params *WebhookSubscriptionsParams) (*WebhookSubscriptionsResponse, error)
GetWebhookSubscriptions gets webhook subscriptions, in order of expiration. Requires an app access token.
func (*Client) PostWebhookSubscription ¶ added in v0.4.2
func (c *Client) PostWebhookSubscription(payload *WebhookSubscriptionPayload) (*WebhookSubscriptionResponse, error)
PostWebhookSubscription ...
func (*Client) RefreshUserAccessToken ¶
func (c *Client) RefreshUserAccessToken(refreshToken string) (*RefreshTokenResponse, error)
RefreshUserAccessToken submits a request to have the longevity of an access token extended. Twitch OAuth2 access tokens have expirations. Token-expiration periods vary in length. You should build your applications in such a way that they are resilient to token authentication failures.
func (*Client) RevokeUserAccessToken ¶
func (c *Client) RevokeUserAccessToken(accessToken string) (*RevokeAccessTokenResponse, error)
RevokeUserAccessToken submits a request to Twitch to have an access token revoked.
Both successful requests and requests with bad tokens return 200 OK with no body. Requests with bad tokens return the same response, as there is no meaningful action a client can take after sending a bad token.
func (*Client) SearchChannels ¶ added in v0.6.0
func (c *Client) SearchChannels(params *SearchChannelsParams) (*SearchChannelsResponse, error)
SearchChannels searches for Twitch channels based on the given search parameters. Unlike GetStreams, this can also return offline channels.
func (*Client) SetAppAccessToken ¶
SetAppAccessToken ...
func (*Client) SetUserAccessToken ¶
SetUserAccessToken ...
func (*Client) UpdateUser ¶
func (c *Client) UpdateUser(params *UpdateUserParams) (*UsersResponse, error)
UpdateUser updates the description of a user specified by a Bearer token.
Required scope: user:edit
func (*Client) UpdateUserExtensions ¶ added in v0.5.7
func (c *Client) UpdateUserExtensions(payload *UpdateUserExtensionsPayload) (*UserActiveExtensionsResponse, error)
UpdateUserExtensions Updates the activation state, extension ID, and/or version number of installed extensions for a specified user, identified by a Bearer token. If you try to activate a given extension under multiple extension types, the last write wins (and there is no guarantee of write order).
Required scope: user:edit:broadcast
func (*Client) ValidateToken ¶ added in v0.5.9
func (c *Client) ValidateToken(accessToken string) (bool, *ValidateTokenResponse, error)
ValidateToken - Validate access token
type Clip ¶
type Clip struct { ID string `json:"id"` URL string `json:"url"` EmbedURL string `json:"embed_url"` BroadcasterID string `json:"broadcaster_id"` BroadcasterName string `json:"broadcaster_name"` CreatorID string `json:"creator_id"` CreatorName string `json:"creator_name"` VideoID string `json:"video_id"` GameID string `json:"game_id"` Language string `json:"language"` Title string `json:"title"` ViewCount int `json:"view_count"` CreatedAt string `json:"created_at"` ThumbnailURL string `json:"thumbnail_url"` }
Clip ...
type ClipEditURL ¶
ClipEditURL ...
type ClipsParams ¶
type ClipsParams struct { // One of the below BroadcasterID string `query:"broadcaster_id"` GameID string `query:"game_id"` IDs []string `query:"id"` // Limit 100 // Optional First int `query:"first,20"` // Maximum 100 After string `query:"after"` Before string `query:"before"` StartedAt Time `query:"started_at"` EndedAt Time `query:"ended_at"` }
ClipsParams ...
type CreateClipParams ¶ added in v0.5.0
type CreateClipParams struct { BroadcasterID string `query:"broadcaster_id"` // Optional HasDelay bool `query:"has_delay,false"` }
CreateClipParams ...
type CreateClipResponse ¶
type CreateClipResponse struct { ResponseCommon Data ManyClipEditURLs }
CreateClipResponse ...
func (*CreateClipResponse) GetClipsCreationRateLimit ¶ added in v0.3.0
func (ccr *CreateClipResponse) GetClipsCreationRateLimit() int
GetClipsCreationRateLimit returns the "Ratelimit-Helixclipscreation-Limit" header as an int.
func (*CreateClipResponse) GetClipsCreationRateLimitRemaining ¶ added in v0.3.0
func (ccr *CreateClipResponse) GetClipsCreationRateLimitRemaining() int
GetClipsCreationRateLimitRemaining returns the "Ratelimit-Helixclipscreation-Remaining" header as an int.
type CreateStreamMarker ¶ added in v0.4.2
type CreateStreamMarker struct { ID string `json:"id"` CreatedAt Time `json:"created_at"` Description string `json:"description"` PositionSeconds int `json:"position_seconds"` }
CreateStreamMarker ...
type CreateStreamMarkerParams ¶ added in v0.4.2
type CreateStreamMarkerParams struct { UserID string `query:"user_id"` // Optional Description string `query:"description"` }
CreateStreamMarkerParams ...
type CreateStreamMarkerResponse ¶ added in v0.4.2
type CreateStreamMarkerResponse struct { ResponseCommon Data ManyCreateStreamMarkers }
CreateStreamMarkerResponse ...
type EntitlementsUploadResponse ¶
type EntitlementsUploadResponse struct { ResponseCommon Data ManyEntitlementsUploadURLs }
EntitlementsUploadResponse ...
type EntitlementsUploadURL ¶
type EntitlementsUploadURL struct {
URL string `json:"url"`
}
EntitlementsUploadURL ...
type ExtensionAnalytic ¶ added in v0.4.0
type ExtensionAnalytic struct { ExtensionID string `json:"extension_id"` URL string `json:"URL"` Type string `json:"type"` DateRange DateRange `json:"date_range"` }
ExtensionAnalytic ...
type ExtensionAnalyticsParams ¶ added in v0.4.0
type ExtensionAnalyticsParams struct { ExtensionID string `query:"extension_id"` First int `query:"first,20"` After string `query:"after"` StartedAt Time `query:"started_at"` EndedAt Time `query:"ended_at"` Type string `query:"type"` }
ExtensionAnalyticsParams ...
type ExtensionAnalyticsResponse ¶ added in v0.4.0
type ExtensionAnalyticsResponse struct { ResponseCommon Data ManyExtensionAnalytics }
ExtensionAnalyticsResponse ...
type Game ¶
type Game struct { ID string `json:"id"` Name string `json:"name"` BoxArtURL string `json:"box_art_url"` }
Game ...
type GameAnalytic ¶
type GameAnalytic struct { GameID string `json:"game_id"` URL string `json:"URL"` Type string `json:"type"` DateRange DateRange `json:"date_range"` }
GameAnalytic ...
type GameAnalyticsParams ¶ added in v0.4.0
type GameAnalyticsParams struct { GameID string `query:"game_id"` First int `query:"first,20"` After string `query:"after"` StartedAt Time `query:"started_at"` EndedAt Time `query:"ended_at"` Type string `query:"type"` }
GameAnalyticsParams ...
type GameAnalyticsResponse ¶
type GameAnalyticsResponse struct { ResponseCommon Data ManyGameAnalytics }
GameAnalyticsResponse ...
type GamesParams ¶
type GamesParams struct { IDs []string `query:"id"` // Limit 100 Names []string `query:"name"` // Limit 100 }
GamesParams ...
type HTTPClient ¶
HTTPClient ...
type HearthstoneHero ¶
type HearthstoneHero struct { Class string `json:"class"` Name string `json:"name"` Type string `json:"type"` }
HearthstoneHero ...
type HearthstoneMetadata ¶
type HearthstoneMetadata struct { Broadcaster HearthstonePlayerData `json:"broadcaster"` Opponent HearthstonePlayerData `json:"opponent"` }
HearthstoneMetadata ...
type HearthstonePlayerData ¶
type HearthstonePlayerData struct {
Hero HearthstoneHero `json:"hero"`
}
HearthstonePlayerData ...
type ManyBans ¶ added in v0.5.5
type ManyBans struct { Bans []Ban `json:"data"` Pagination Pagination `json:"pagination"` }
ManyBans ...
type ManyClipEditURLs ¶
type ManyClipEditURLs struct {
ClipEditURLs []ClipEditURL `json:"data"`
}
ManyClipEditURLs ...
type ManyClips ¶
type ManyClips struct { Clips []Clip `json:"data"` Pagination Pagination `json:"pagination"` }
ManyClips ...
type ManyCreateStreamMarkers ¶ added in v0.4.2
type ManyCreateStreamMarkers struct {
CreateStreamMarkers []CreateStreamMarker `json:"data"`
}
ManyCreateStreamMarkers ...
type ManyEntitlementsUploadURLs ¶
type ManyEntitlementsUploadURLs struct {
URLs []EntitlementsUploadURL `json:"data"`
}
ManyEntitlementsUploadURLs ...
type ManyExtensionAnalytics ¶ added in v0.4.0
type ManyExtensionAnalytics struct { ExtensionAnalytics []ExtensionAnalytic `json:"data"` Pagination Pagination `json:"pagination"` }
ManyExtensionAnalytics ...
type ManyFollows ¶
type ManyFollows struct { Total int `json:"total"` Follows []UserFollow `json:"data"` Pagination Pagination `json:"pagination"` }
ManyFollows ...
type ManyGameAnalytics ¶
type ManyGameAnalytics struct { GameAnalytics []GameAnalytic `json:"data"` Pagination Pagination `json:"pagination"` }
ManyGameAnalytics ...
type ManyGamesWithPagination ¶
type ManyGamesWithPagination struct { ManyGames Pagination Pagination `json:"pagination"` }
ManyGamesWithPagination ...
type ManySearchChannels ¶ added in v0.6.0
type ManySearchChannels struct { Channels []Channel `json:"data"` Pagination Pagination `json:"pagination"` }
ManySearchChannels is the response data from SearchChannels
type ManyStreamMarkers ¶ added in v0.4.1
type ManyStreamMarkers struct { StreamMarkers []StreamMarker `json:"data"` Pagination Pagination `json:"pagination"` }
ManyStreamMarkers ...
type ManyStreams ¶
type ManyStreams struct { Streams []Stream `json:"data"` Pagination Pagination `json:"pagination"` }
ManyStreams ...
type ManyStreamsMetadata ¶
type ManyStreamsMetadata struct { Streams []StreamMetadata `json:"data"` Pagination Pagination `json:"pagination"` }
ManyStreamsMetadata ...
type ManySubscriptions ¶ added in v0.5.3
type ManySubscriptions struct { Subscriptions []Subscription `json:"data"` Pagination Pagination `json:"pagination"` }
ManySubscriptions ...
type ManyUserBitTotals ¶
type ManyUserBitTotals struct { Total int `json:"total"` DateRange DateRange `json:"date_range"` UserBitTotals []UserBitTotal `json:"data"` }
ManyUserBitTotals ...
type ManyUserExtensions ¶ added in v0.5.6
type ManyUserExtensions struct {
UserExtensions []UserExtension `json:"data"`
}
ManyUserExtensions ...
type ManyVideos ¶
type ManyVideos struct { Videos []Video `json:"data"` Pagination Pagination `json:"pagination"` }
ManyVideos ...
type ManyWebhookSubscriptions ¶ added in v0.3.1
type ManyWebhookSubscriptions struct { Total int `json:"total"` WebhookSubscriptions []WebhookSubscription `json:"data"` Pagination Pagination `json:"pagination"` }
ManyWebhookSubscriptions ...
type Marker ¶ added in v0.4.1
type Marker struct { ID string `json:"id"` CreatedAt Time `json:"created_at"` Description string `json:"description"` PositionSeconds int `json:"position_seconds"` URL string `json:"URL"` }
Marker ...
type Options ¶
type Options struct { ClientID string ClientSecret string AppAccessToken string UserAccessToken string UserAgent string RedirectURI string HTTPClient HTTPClient RateLimitFunc RateLimitFunc APIBaseURL string }
Options ...
type OverwatchBroadcaster ¶
type OverwatchBroadcaster struct {
Hero OverwatchHero `json:"hero"`
}
OverwatchBroadcaster ...
type OverwatchHero ¶
type OverwatchHero struct { Ability string `json:"ability"` Name string `json:"name"` Role string `json:"role"` }
OverwatchHero ...
type OverwatchMetadata ¶
type OverwatchMetadata struct {
Broadcaster OverwatchBroadcaster `json:"broadcaster"`
}
OverwatchMetadata ...
type RefreshTokenResponse ¶
type RefreshTokenResponse struct { ResponseCommon Data AccessCredentials }
RefreshTokenResponse ...
type Response ¶
type Response struct { ResponseCommon Data interface{} }
Response ...
func (*Response) HydrateResponseCommon ¶ added in v0.5.7
func (r *Response) HydrateResponseCommon(rc *ResponseCommon)
HydrateResponseCommon copies the content of the source response's ResponseCommon to the supplied ResponseCommon argument
type ResponseCommon ¶
type ResponseCommon struct { StatusCode int Header http.Header Error string `json:"error"` ErrorStatus int `json:"status"` ErrorMessage string `json:"message"` }
ResponseCommon ...
func (*ResponseCommon) GetRateLimit ¶ added in v0.3.0
func (rc *ResponseCommon) GetRateLimit() int
GetRateLimit returns the "RateLimit-Limit" header as an int.
func (*ResponseCommon) GetRateLimitRemaining ¶ added in v0.3.0
func (rc *ResponseCommon) GetRateLimitRemaining() int
GetRateLimitRemaining returns the "RateLimit-Remaining" header as an int.
func (*ResponseCommon) GetRateLimitReset ¶ added in v0.3.0
func (rc *ResponseCommon) GetRateLimitReset() int
GetRateLimitReset returns the "RateLimit-Reset" header as an int.
type RevokeAccessTokenResponse ¶
type RevokeAccessTokenResponse struct {
ResponseCommon
}
RevokeAccessTokenResponse ...
type SearchChannelsParams ¶ added in v0.6.0
type SearchChannelsParams struct { Channel string `query:"query"` After string `query:"after"` First int `query:"first,20"` // Limit 100 LiveOnly bool `query:"live_only"` }
SearchChannelsParams is parameters for SearchChannels
type SearchChannelsResponse ¶ added in v0.6.0
type SearchChannelsResponse struct { ResponseCommon Data ManySearchChannels }
SearchChannelsResponse is the response from SearchChannels
type Stream ¶
type Stream struct { ID string `json:"id"` UserID string `json:"user_id"` UserName string `json:"user_name"` GameID string `json:"game_id"` TagIDs []string `json:"tag_ids"` Type string `json:"type"` Title string `json:"title"` ViewerCount int `json:"viewer_count"` StartedAt time.Time `json:"started_at"` Language string `json:"language"` ThumbnailURL string `json:"thumbnail_url"` }
Stream ...
type StreamMarker ¶ added in v0.4.1
type StreamMarker struct { UserID string `json:"user_id"` UserName string `json:"user_name"` Videos []VideoMarker `json:"videos"` }
StreamMarker ...
type StreamMarkersParams ¶ added in v0.4.1
type StreamMarkersParams struct { UserID string `query:"user_id"` VideoID string `query:"video_id"` // Optional After string `query:"after"` Before string `query:"before"` First int `query:"first,20"` // Limit 100 }
StreamMarkersParams requires _either_ UserID or VideoID set
UserID: fetches stream markers of the current livestream of the given user (VOD recording must be enabled). VideoID: fetches streams markers of the VOD.
type StreamMarkersResponse ¶ added in v0.4.1
type StreamMarkersResponse struct { ResponseCommon Data ManyStreamMarkers }
StreamMarkersResponse ...
type StreamMetadata ¶
type StreamMetadata struct { UserID string `json:"user_id"` UserName string `json:"user_name"` GameID string `json:"game_id"` Hearthstone HearthstoneMetadata `json:"hearthstone"` Overwatch OverwatchMetadata `json:"overwatch"` }
StreamMetadata ...
type StreamsMetadataResponse ¶
type StreamsMetadataResponse struct { ResponseCommon Data ManyStreamsMetadata }
StreamsMetadataResponse ...
func (*StreamsMetadataResponse) GetStreamsMetadataRateLimit ¶ added in v0.3.0
func (sr *StreamsMetadataResponse) GetStreamsMetadataRateLimit() int
GetStreamsMetadataRateLimit returns the "Ratelimit-Helixstreamsmetadata-Limit" header as an int.
func (*StreamsMetadataResponse) GetStreamsMetadataRateLimitRemaining ¶ added in v0.3.0
func (sr *StreamsMetadataResponse) GetStreamsMetadataRateLimitRemaining() int
GetStreamsMetadataRateLimitRemaining returns the "Ratelimit-Helixstreamsmetadata-Remaining" header as an int.
type StreamsParams ¶
type StreamsParams struct { After string `query:"after"` Before string `query:"before"` First int `query:"first,20"` // Limit 100 GameIDs []string `query:"game_id"` // Limit 100 Language []string `query:"language"` // Limit 100 Type string `query:"type,all"` // "all" (default), "live" and "vodcast" UserIDs []string `query:"user_id"` // limit 100 UserLogins []string `query:"user_login"` // limit 100 }
StreamsParams ...
type StreamsResponse ¶
type StreamsResponse struct { ResponseCommon Data ManyStreams }
StreamsResponse ...
type Subscription ¶ added in v0.5.3
type Subscription struct { BroadcasterID string `json:"broadcaster_id"` BroadcasterName string `json:"broadcaster_name"` IsGift bool `json:"is_gift"` Tier string `json:"tier"` PlanName string `json:"plan_name"` UserID string `json:"user_id"` UserName string `json:"user_name"` }
Subscription ...
type SubscriptionsParams ¶ added in v0.5.3
type SubscriptionsParams struct { BroadcasterID string `query:"broadcaster_id"` // Limit 1 UserID []string `query:"user_id"` // Limit 100 }
SubscriptionsParams ...
type SubscriptionsResponse ¶ added in v0.5.3
type SubscriptionsResponse struct { ResponseCommon Data ManySubscriptions }
SubscriptionsResponse ...
type Time ¶
Time is our custom time struct.
func (*Time) UnmarshalJSON ¶
UnmarshalJSON is our custom datetime unmarshaller. Twitch sometimes returns datetimes as empty strings, which casuses issues with the native time UnmarshalJSON method when decoding the JSON string. Here we hanlde that scenario, by returning a zero time value for any JSON time field that is either an empty string or "null".
type TopGamesParams ¶
type TopGamesParams struct { After string `query:"after"` Before string `query:"before"` First int `query:"first,20"` // Limit 100 }
TopGamesParams ...
type TopGamesResponse ¶
type TopGamesResponse struct { ResponseCommon Data ManyGamesWithPagination }
TopGamesResponse ...
type UpdateUserExtensionsPayload ¶ added in v0.5.7
type UpdateUserExtensionsPayload struct { Component map[string]UserActiveExtensionInfo `json:"component,omitempty"` Overlay map[string]UserActiveExtensionInfo `json:"overlay,omitempty"` Panel map[string]UserActiveExtensionInfo `json:"panel,omitempty"` }
type UpdateUserParams ¶ added in v0.5.0
type UpdateUserParams struct {
Description string `query:"description"`
}
UpdateUserParams ...
type User ¶
type User struct { ID string `json:"id"` Login string `json:"login"` DisplayName string `json:"display_name"` Type string `json:"type"` BroadcasterType string `json:"broadcaster_type"` Description string `json:"description"` ProfileImageURL string `json:"profile_image_url"` OfflineImageURL string `json:"offline_image_url"` ViewCount int `json:"view_count"` Email string `json:"email"` }
User ...
type UserAccessTokenResponse ¶
type UserAccessTokenResponse struct { ResponseCommon Data AccessCredentials }
UserAccessTokenResponse ...
type UserActiveExtension ¶ added in v0.5.6
type UserActiveExtension struct { Component map[string]UserActiveExtensionInfo `json:"component"` Overlay map[string]UserActiveExtensionInfo `json:"overlay"` Panel map[string]UserActiveExtensionInfo `json:"panel"` }
UserActiveExtension ...
type UserActiveExtensionInfo ¶ added in v0.5.6
type UserActiveExtensionInfo struct { Active bool `json:"active"` ID string `json:"id"` Name string `json:"name"` Version string `json:"version"` X int `json:"x"` Y int `json:"y"` }
UserActiveExtensionInfo ...
type UserActiveExtensionSet ¶ added in v0.5.6
type UserActiveExtensionSet struct {
UserActiveExtensions UserActiveExtension `json:"data"`
}
UserActiveExtensionSet ...
type UserActiveExtensionsParams ¶ added in v0.5.6
type UserActiveExtensionsParams struct {
UserID string `query:"user_id"` // Optional, limit 1
}
UserActiveExtensionsParams ...
type UserActiveExtensionsResponse ¶ added in v0.5.6
type UserActiveExtensionsResponse struct { ResponseCommon Data UserActiveExtensionSet }
UserActiveExtensionsResponse ...
type UserBitTotal ¶
type UserBitTotal struct { UserID string `json:"user_id"` UserName string `json:"user_name"` Rank int `json:"rank"` Score int `json:"score"` }
UserBitTotal ...
type UserExtension ¶ added in v0.5.6
type UserExtension struct { CanActivate bool `json:"can_activate"` ID string `json:"id"` Name string `json:"name"` Type []string `json:"type"` Version string `json:"version"` }
UserExtension ...
type UserExtensionsResponse ¶ added in v0.5.6
type UserExtensionsResponse struct { ResponseCommon Data ManyUserExtensions }
UserExtensionsResponse ...
type UserFollow ¶
type UserFollow struct { FromID string `json:"from_id"` FromName string `json:"from_name"` ToID string `json:"to_id"` ToName string `json:"to_name"` FollowedAt time.Time `json:"followed_at"` }
UserFollow ...
type UsersFollowsParams ¶
type UsersFollowsParams struct { After string `query:"after"` First int `query:"first,20"` // Limit 100 FromID string `query:"from_id"` ToID string `query:"to_id"` }
UsersFollowsParams ...
type UsersFollowsResponse ¶
type UsersFollowsResponse struct { ResponseCommon Data ManyFollows }
UsersFollowsResponse ...
type UsersParams ¶
type UsersParams struct { IDs []string `query:"id"` // Limit 100 Logins []string `query:"login"` // Limit 100 }
UsersParams ...
type ValidateTokenResponse ¶ added in v0.5.9
type ValidateTokenResponse struct { ResponseCommon Data validateTokenDetails }
ValidateTokenResponse ...
type Video ¶
type Video struct { ID string `json:"id"` UserID string `json:"user_id"` UserName string `json:"user_name"` Title string `json:"title"` Description string `json:"description"` CreatedAt string `json:"created_at"` PublishedAt string `json:"published_at"` URL string `json:"url"` ThumbnailURL string `json:"thumbnail_url"` Viewable string `json:"viewable"` ViewCount int `json:"view_count"` Language string `json:"language"` Type string `json:"type"` Duration string `json:"duration"` }
Video ...
type VideoMarker ¶ added in v0.4.1
VideoMarker ...
type VideosParams ¶
type VideosParams struct { IDs []string `query:"id"` // Limit 100 UserID string `query:"user_id"` // Limit 1 GameID string `query:"game_id"` // Limit 1 // Optional After string `query:"after"` Before string `query:"before"` First int `query:"first,20"` // Limit 100 Language string `query:"language"` // Limit 1 Period string `query:"period,all"` // "all" (default), "day", "month", and "week" Sort string `query:"sort,time"` // "time" (default), "trending", and "views" Type string `query:"type,all"` // "all" (default), "upload", "archive", and "highlight" }
VideosParams ...
type VideosResponse ¶
type VideosResponse struct { ResponseCommon Data ManyVideos }
VideosResponse ...
type WebhookSubscription ¶ added in v0.3.1
type WebhookSubscription struct { Topic string `json:"topic"` Callback string `json:"callback"` ExpiresAt Time `json:"expires_at"` }
WebhookSubscription ...
type WebhookSubscriptionPayload ¶ added in v0.4.2
type WebhookSubscriptionPayload struct { Mode string `json:"hub.mode"` Topic string `json:"hub.topic"` Callback string `json:"hub.callback"` LeaseSeconds int `json:"hub.lease_seconds,omitempty"` Secret string `json:"hub.secret,omitempty"` }
WebhookSubscriptionPayload ...
type WebhookSubscriptionResponse ¶ added in v0.4.2
type WebhookSubscriptionResponse struct {
ResponseCommon
}
WebhookSubscriptionResponse ...
type WebhookSubscriptionsParams ¶ added in v0.3.1
type WebhookSubscriptionsParams struct { After string `query:"after"` First int `query:"first,20"` // Limit 100 }
WebhookSubscriptionsParams ...
type WebhookSubscriptionsResponse ¶ added in v0.3.1
type WebhookSubscriptionsResponse struct { ResponseCommon Data ManyWebhookSubscriptions }
WebhookSubscriptionsResponse ...
type WebhookTopic ¶ added in v0.4.2
type WebhookTopic int
WebhookTopic is a topic that relates to a specific webhook event.
const ( UserFollowsTopic WebhookTopic = iota StreamChangedTopic UserChangedTopic GameAnalyticsTopic ExtensionAnalyticsTopic )
Enumerated webhook topics
func GetWebhookTopicFromRequest ¶ added in v0.4.2
func GetWebhookTopicFromRequest(req *http.Request) WebhookTopic
GetWebhookTopicFromRequest inspects the "Link" request header to determine if it matches against any recognised webhooks topics. The matched topic is returned. Otherwise -1 is returned.