Documentation
¶
Index ¶
- Constants
- Variables
- func GetWebhookTopicValuesFromRequest(req *http.Request, topic WebhookTopic) map[string]string
- type AppAccessCredentials
- type AppAccessTokenResponse
- type BitsLeaderboardParams
- type BitsLeaderboardResponse
- 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() (*AppAccessTokenResponse, error)
- func (c *Client) GetAuthorizationURL(state string, forceVerify bool) string
- 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) 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) SetAppAccessToken(accessToken string)
- func (c *Client) SetRedirectURI(uri string)
- func (c *Client) SetScopes(scopes []string)
- func (c *Client) SetUserAccessToken(accessToken string)
- func (c *Client) SetUserAgent(userAgent string)
- func (c *Client) UpdateUser(params *UpdateUserParams) (*UsersResponse, 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 ManyClipEditURLs
- type ManyClips
- type ManyCreateStreamMarkers
- type ManyEntitlementsUploadURLs
- type ManyExtensionAnalytics
- type ManyFollows
- type ManyGameAnalytics
- type ManyGames
- type ManyGamesWithPagination
- type ManyStreamMarkers
- type ManyStreams
- type ManyStreamsMetadata
- type ManySubscriptions
- type ManyUserBitTotals
- 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 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 UpdateUserParams
- type User
- type UserAccessCredentials
- type UserAccessTokenResponse
- type UserBitTotal
- type UserFollow
- type UsersFollowsParams
- type UsersFollowsResponse
- type UsersParams
- type UsersResponse
- type Video
- type VideoMarker
- type VideosParams
- type VideosResponse
- type WebhookSubscription
- type WebhookSubscriptionPayload
- type WebhookSubscriptionResponse
- type WebhookSubscriptionsParams
- type WebhookSubscriptionsResponse
- type WebhookTopic
Constants ¶
const ( // APIBaseURL is the base URL for composing API requests. APIBaseURL = "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 AppAccessCredentials ¶
type AppAccessCredentials struct { AccessToken string `json:"access_token"` ExpiresIn int `json:"expires_in"` }
AppAccessCredentials ...
type AppAccessTokenResponse ¶
type AppAccessTokenResponse struct { ResponseCommon Data AppAccessCredentials }
AppAccessTokenResponse ...
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 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() (*AppAccessTokenResponse, error)
GetAppAccessToken ...
func (*Client) GetAuthorizationURL ¶
GetAuthorizationURL ...
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 ...
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) 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) 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
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 ¶
func (ccr *CreateClipResponse) GetClipsCreationRateLimit() int
GetClipsCreationRateLimit returns the "Ratelimit-Helixclipscreation-Limit" header as an int.
func (*CreateClipResponse) GetClipsCreationRateLimitRemaining ¶
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 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 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 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 Scopes []string HTTPClient HTTPClient RateLimitFunc RateLimitFunc }
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 UserAccessCredentials }
RefreshTokenResponse ...
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 ¶
func (rc *ResponseCommon) GetRateLimit() int
GetRateLimit returns the "RateLimit-Limit" header as an int.
func (*ResponseCommon) GetRateLimitRemaining ¶
func (rc *ResponseCommon) GetRateLimitRemaining() int
GetRateLimitRemaining returns the "RateLimit-Remaining" header as an int.
func (*ResponseCommon) GetRateLimitReset ¶
func (rc *ResponseCommon) GetRateLimitReset() int
GetRateLimitReset returns the "RateLimit-Reset" header as an int.
type RevokeAccessTokenResponse ¶
type RevokeAccessTokenResponse struct {
ResponseCommon
}
RevokeAccessTokenResponse ...
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 ¶
func (sr *StreamsMetadataResponse) GetStreamsMetadataRateLimit() int
GetStreamsMetadataRateLimit returns the "Ratelimit-Helixstreamsmetadata-Limit" header as an int.
func (*StreamsMetadataResponse) GetStreamsMetadataRateLimitRemaining ¶
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 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 UserAccessCredentials ¶
type UserAccessCredentials struct { AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` ExpiresIn int `json:"expires_in"` Scopes []string `json:"scope"` }
UserAccessCredentials ...
type UserAccessTokenResponse ¶
type UserAccessTokenResponse struct { ResponseCommon Data UserAccessCredentials }
UserAccessTokenResponse ...
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 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 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.