Documentation ¶
Overview ¶
Package twitchapi is used for twitch's API
Package twitchapi is used for twitch's API ¶
Package twitchapi is used for twitch's API ¶
Package twitchapi is used for twitch's API ¶
Package twitchapi is used for twitch's API ¶
Package twitchapi is used for twitch's API ¶
Package twitchapi is used for twitch's API ¶
Package twitchapi is used for twitch's API ¶
Package twitchapi is used for twitch's API ¶
Package twitchapi is used for twitch's API
Index ¶
- Constants
- type Badge
- type Channel
- type ChannelAuthenticated
- type ChannelUpdate
- type ChatterInfo
- type Cheeremotes
- type CommercialLength
- type CommercialResponse
- type Communities
- type Community
- type CommunityIDs
- type EditorList
- type EmoteList
- type EmoteMap
- type Emoticon
- type Following
- type FollowsList
- type HiddenKraken
- type Stream
- type Subscriber
- type Subscribers
- type Team
- type Teams
- type TokenValidation
- type TwitchKraken
- func (tk *TwitchKraken) AddChannelToCommunities(oauth, channelID string, communityIDs CommunityIDs) (jsoerr *network.JSONError, err error)
- func (tk *TwitchKraken) GetChannel(channelID string) (resp *Channel, jsoerr *network.JSONError, err error)
- func (tk *TwitchKraken) GetChannelAuthenticated(oauth string) (resp *ChannelAuthenticated, jsoerr *network.JSONError, err error)
- func (tk *TwitchKraken) GetChannelCommunities(channelID string) (resp *Communities, jsoerr *network.JSONError, err error)
- func (tk *TwitchKraken) GetChannelEditors(oauth, channelID string) (resp *EditorList, jsoerr *network.JSONError, err error)
- func (tk *TwitchKraken) GetChannelFollows(channelID, optLimit, optCursor, optOffset, optDirection string) (resp *FollowsList, jsoerr *network.JSONError, err error)
- func (tk *TwitchKraken) GetChannelSubscribers(oauth, channelID, optLimit, optOffset, optDirection string) (resp *Subscribers, jsoerr *network.JSONError, err error)
- func (tk *TwitchKraken) GetChannelTeams(channelID string) (resp *Teams, jsoerr *network.JSONError, err error)
- func (tk *TwitchKraken) GetChannelVideos(channelID, optLimit, optOffset, optBroadcastType, optLanguage, optSort string) (resp *Videos, jsoerr *network.JSONError, err error)
- func (tk *TwitchKraken) GetCheeremotesForChannel(channelID string) (resp *Cheeremotes, jsoerr *network.JSONError, err error)
- func (tk *TwitchKraken) GetEmoticonMap(emotesets []string) (resp *EmoteMap, jsoerr *network.JSONError, err error)
- func (tk *TwitchKraken) GetEmoticons(emotesets []string) (resp *EmoteList, jsoerr *network.JSONError, err error)
- func (tk *TwitchKraken) GetGlobalCheeremotes() (resp *Cheeremotes, jsoerr *network.JSONError, err error)
- func (tk *TwitchKraken) GetOauthToken(forceAuth bool, callbackURL, scopes string, callback func(token string)) (url string)
- func (tk *TwitchKraken) GetStream(channelID, optType string) (resp *Stream, jsoerr *network.JSONError, err error)
- func (tk *TwitchKraken) GetUserByName(name string) (resp *Users, jsoerr *network.JSONError, err error)
- func (tk *TwitchKraken) GetUsersByNames(names []string) (resp *Users, jsoerr *network.JSONError, err error)
- func (tk *TwitchKraken) IsSubscribedToChannel(oauth, channelID, userID string) (resp *Subscriber, jsoerr *network.JSONError, err error)
- func (tk *TwitchKraken) IsUserFollowingChannel(userID, channelID string) (resp *Following, jsoerr *network.JSONError, err error)
- func (tk *TwitchKraken) RemoveChannelFromAllCommunites(oauth, channelID string) (jsoerr *network.JSONError, err error)
- func (tk *TwitchKraken) ResetStreamkey(oauth, channelID string) (resp *ChannelAuthenticated, jsoerr *network.JSONError, err error)
- func (tk *TwitchKraken) RevokeToken(oauth string)
- func (tk *TwitchKraken) RunCommercial(oauth, channelID string, length *CommercialLength) (resp *CommercialResponse, jsoerr *network.JSONError, err error)
- func (tk *TwitchKraken) UpdateChannel(oauth, channelID string, data *ChannelUpdate) (resp *Channel, jsoerr *network.JSONError, err error)
- func (tk *TwitchKraken) ValidateToken(oauth string) (resp *TokenValidation, jsoerr *network.JSONError, err error)
- type User
- type Users
- type Video
- type Videos
Constants ¶
const APIVersionHeader = "application/vnd.twitchtv.v5+json"
APIVersionHeader is the common header to set the selected api version (v5)
const AppName string = "goPurple/twitchapi"
AppName is the name of the application
const BaseURL = "https://api.twitch.tv/kraken"
BaseURL of the twitch kraken API
const FullVersion string = AppName + VersionMajor + "." + VersionMinor + VersionBuild
FullVersion contains the full name and version of this package in a printable string
const VersionBuild string = "s"
VersionBuild is the type of this release. s(table), b(eta), d(evelopment), n(ightly)
const VersionMajor string = "0"
VersionMajor 0 means in development, >1 ensures compatibility with each minor version, but breakes with new major version
const VersionMinor string = "2"
VersionMinor introduces changes that require a new version number. If the major version is 0, they are likely to break compatibility
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Channel ¶
type Channel struct { ID json.Number `json:"_id"` Mature bool `json:"mature"` Partner bool `json:"partner"` Status string `json:"status"` BroadcasterLanguage string `json:"broadcaster_language"` DisplayName string `json:"display_name"` Game string `json:"game"` Language string `json:"language"` Name string `json:"name"` Logo string `json:"logo"` VideoBanner string `json:"video_banner"` ProfileBanner string `json:"profile_banner"` ProfileBannerBackgroundColor string `json:"profile_banner_background_color"` URL string `json:"url"` Description string `json:"description"` BroadcasterType string `json:"broadcaster_type"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` Views int `json:"views"` Followers int `json:"followers"` }
Channel contains public information about a channel
type ChannelAuthenticated ¶
type ChannelAuthenticated struct { ID json.Number `json:"_id"` Mature bool `json:"mature"` Partner bool `json:"partner"` Status string `json:"status"` BroadcasterLanguage string `json:"broadcaster_language"` DisplayName string `json:"display_name"` Game string `json:"game"` Language string `json:"language"` Name string `json:"name"` Logo string `json:"logo"` VideoBanner string `json:"video_banner"` ProfileBanner string `json:"profile_banner"` ProfileBannerBackgroundColor string `json:"profile_banner_background_color"` URL string `json:"url"` BroadcasterType string `json:"broadcaster_type"` Description string `json:"description"` StreamKey string `json:"stream_key"` Email string `json:"email"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` Views int `json:"views"` Followers int `json:"followers"` }
ChannelAuthenticated contains all available information about a channel, including private information
type ChannelUpdate ¶
type ChannelUpdate struct { Data struct { Status string `json:"status,omitempty"` Game string `json:"game,omitempty"` Delay string `json:"delay,omitempty"` ChannelFeedEnabled bool `json:"channel_feed_enabled,omitempty"` } `json:"channel"` }
ChannelUpdate contains the Information you can set through the API
type ChatterInfo ¶
type ChatterInfo struct { ID string `json:"_id"` Login string `json:"login"` DisplayName string `json:"display_name"` Color string `json:"color"` IsVerifiedBot bool `json:"is_verified_bot"` IsKnownBot bool `json:"is_known_bot"` Badges []Badge `json:"badges"` }
ChatterInfo contains chat related information about a viewer in a specific chat
type Cheeremotes ¶
type Cheeremotes struct { Actions []struct { Prefix string `json:"prefix"` Scales []string `json:"scales"` Tiers []struct { MinBits int `json:"min_bits"` ID string `json:"id"` Color string `json:"color"` Images struct { Dark struct { Animated struct { Num1 string `json:"1"` Num2 string `json:"2"` Num3 string `json:"3"` Num4 string `json:"4"` One5 string `json:"1.5"` } `json:"animated"` Static struct { Num1 string `json:"1"` Num2 string `json:"2"` Num3 string `json:"3"` Num4 string `json:"4"` One5 string `json:"1.5"` } `json:"static"` } `json:"dark"` Light struct { Animated struct { Num1 string `json:"1"` Num2 string `json:"2"` Num3 string `json:"3"` Num4 string `json:"4"` One5 string `json:"1.5"` } `json:"animated"` Static struct { Num1 string `json:"1"` Num2 string `json:"2"` Num3 string `json:"3"` Num4 string `json:"4"` One5 string `json:"1.5"` } `json:"static"` } `json:"light"` } `json:"images"` } `json:"tiers"` Backgrounds []string `json:"backgrounds"` States []string `json:"states"` Type string `json:"type"` UpdatedAt time.Time `json:"updated_at"` Priority int `json:"priority"` } `json:"actions"` }
Cheeremotes struct
type CommercialLength ¶
type CommercialLength struct {
Length int `json:"Length"`
}
CommercialLength is..well, the length of a commercial
type CommercialResponse ¶
type CommercialResponse struct { Length int `json:"Length"` Message string `json:"Message"` RetryAfter int `json:"RetryAfter"` }
CommercialResponse is a response for a requested commercial
type Communities ¶
type Communities struct {
Communities []Community `json:"communities"`
}
Communities is a list of communities
type Community ¶
type Community struct { ID json.Number `json:"_id"` AvatarImageURL string `json:"avatar_image_url"` CoverImageURL string `json:"cover_image_url"` Description string `json:"description"` DescriptionHTML string `json:"description_html"` Language string `json:"language"` Name string `json:"name"` OwnerID string `json:"owner_id"` Rules string `json:"rules"` RulesHTML string `json:"rules_html"` Summary string `json:"summary"` }
Community contains information about a community
type CommunityIDs ¶
type CommunityIDs struct {
CommunityIDs []string `json:"community_ids"`
}
CommunityIDs a list of community ids
type EditorList ¶
type EditorList struct {
Editors []User `json:"users"`
}
EditorList contains a list of users that have the editor permission
type EmoteList ¶
type EmoteList struct {
Emoticons []Emoticon `json:"emoticons"`
}
EmoteList is a list of emotes
type Emoticon ¶
type Emoticon struct { Code string `json:"code"` EmoticonSet int `json:"emoticon_set"` ID int `json:"id"` }
Emoticon contains information about an emote
type Following ¶
type Following struct { CreatedAt time.Time `json:"created_at"` Channel Channel `json:"channel"` Notifications bool `json:"notifications"` }
Following contains information about a follow relation of a user
type FollowsList ¶
type FollowsList struct { Cursor string `json:"_cursor"` Total int `json:"_total"` Follows []struct { CreatedAt string `json:"created_at"` Notifications bool `json:"notifications"` User User `json:"user"` } }
FollowsList contains information about whom a channel follows
type HiddenKraken ¶
type HiddenKraken struct {
Tk *TwitchKraken
}
HiddenKraken exposes hidden, non-supported functions of the twitch kraken api (v5) use with caution, those might break more likely
func (*HiddenKraken) GetChatInformationForUser ¶
func (htk *HiddenKraken) GetChatInformationForUser(userID string) (resp *ChatterInfo, jsoerr *network.JSONError, err error)
GetChatInformationForUser returns information about a user related to their own chat
func (*HiddenKraken) GetChatInformationForUserByChannel ¶
func (htk *HiddenKraken) GetChatInformationForUserByChannel(userID, channelID string) (resp *ChatterInfo, jsoerr *network.JSONError, err error)
GetChatInformationForUserByChannel returns information about a user related to any chat
type Stream ¶
type Stream struct { Stream struct { ID json.Number `json:"_id"` Game string `json:"game"` Viewers json.Number `json:"viewers"` VideoHeight json.Number `json:"video_height"` AverageFps json.Number `json:"average_fps"` Delay json.Number `json:"delay"` CreatedAt time.Time `json:"created_at"` IsPlaylist bool `json:"is_playlist"` StreamType string `json:"stream_type"` Preview struct { Small string `json:"small"` Medium string `json:"medium"` Large string `json:"large"` Template string `json:"template"` } `json:"preview"` Chan Channel `json:"channel"` } `json:"stream"` }
Stream contains information about a stream
type Subscriber ¶
type Subscriber struct { ID json.Number `json:"_id"` CreatedAt time.Time `json:"created_at"` SubPlan string `json:"sub_plan"` SubPlanName string `json:"sub_plan_name"` Subscriber User `json:"user"` }
Subscriber contains information about a subscriber on a channel
type Subscribers ¶
type Subscribers struct { Total int `json:"_total"` Subscribers []Subscriber `json:"subscriptions"` }
Subscribers is a list of Subscribers
type Team ¶
type Team struct { ID int `json:"_id"` Background string `json:"background"` Banner string `json:"banner"` CreatedAt string `json:"created_at"` DisplayName string `json:"display_name"` Info string `json:"info"` Logo string `json:"logo"` Name string `json:"name"` UpdatedAt string `json:"updated_at"` }
Team contains information about a team
type TokenValidation ¶
type TokenValidation struct { Identified bool `json:"identified"` Token struct { Valid bool `json:"valid"` Authorization struct { Scopes []string `json:"scopes"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } `json:"authorization"` UserName string `json:"user_name"` ClientID string `json:"client_id"` } `json:"token"` Links struct { Channel string `json:"channel"` Chat string `json:"chat"` Teams string `json:"teams"` User string `json:"user"` Users string `json:"users"` Streams string `json:"streams"` Ingests string `json:"ingests"` Channels string `json:"channels"` } `json:"_links"` }
TokenValidation is the twitch api response for token validation
type TwitchKraken ¶
type TwitchKraken struct {
ClientID string
}
TwitchKraken exposes the twitch kraken API (v5)
func (*TwitchKraken) AddChannelToCommunities ¶
func (tk *TwitchKraken) AddChannelToCommunities(oauth, channelID string, communityIDs CommunityIDs) (jsoerr *network.JSONError, err error)
AddChannelToCommunities adds a channel to one or more communities
func (*TwitchKraken) GetChannel ¶
func (tk *TwitchKraken) GetChannel(channelID string) (resp *Channel, jsoerr *network.JSONError, err error)
GetChannel returns public information about a channel
func (*TwitchKraken) GetChannelAuthenticated ¶
func (tk *TwitchKraken) GetChannelAuthenticated(oauth string) (resp *ChannelAuthenticated, jsoerr *network.JSONError, err error)
GetChannelAuthenticated returns authenticated channel information
func (*TwitchKraken) GetChannelCommunities ¶
func (tk *TwitchKraken) GetChannelCommunities(channelID string) (resp *Communities, jsoerr *network.JSONError, err error)
GetChannelCommunities returns a list of all communities a channel is part of
func (*TwitchKraken) GetChannelEditors ¶
func (tk *TwitchKraken) GetChannelEditors(oauth, channelID string) (resp *EditorList, jsoerr *network.JSONError, err error)
GetChannelEditors returns a list of all editors for a channel
func (*TwitchKraken) GetChannelFollows ¶
func (tk *TwitchKraken) GetChannelFollows(channelID, optLimit, optCursor, optOffset, optDirection string) (resp *FollowsList, jsoerr *network.JSONError, err error)
GetChannelFollows fetches a list of all channels a channel follows
func (*TwitchKraken) GetChannelSubscribers ¶
func (tk *TwitchKraken) GetChannelSubscribers(oauth, channelID, optLimit, optOffset, optDirection string) (resp *Subscribers, jsoerr *network.JSONError, err error)
GetChannelSubscribers returns a list of all channel subscribers
func (*TwitchKraken) GetChannelTeams ¶
func (tk *TwitchKraken) GetChannelTeams(channelID string) (resp *Teams, jsoerr *network.JSONError, err error)
GetChannelTeams returns a list of teams the channel is part of
func (*TwitchKraken) GetChannelVideos ¶
func (tk *TwitchKraken) GetChannelVideos(channelID, optLimit, optOffset, optBroadcastType, optLanguage, optSort string) (resp *Videos, jsoerr *network.JSONError, err error)
GetChannelVideos returns a list of all video on the channel
func (*TwitchKraken) GetCheeremotesForChannel ¶
func (tk *TwitchKraken) GetCheeremotesForChannel(channelID string) (resp *Cheeremotes, jsoerr *network.JSONError, err error)
GetCheeremotesForChannel returns channel specific cheeremotes
func (*TwitchKraken) GetEmoticonMap ¶
func (tk *TwitchKraken) GetEmoticonMap(emotesets []string) (resp *EmoteMap, jsoerr *network.JSONError, err error)
GetEmoticonMap fetches a list of all! emotes on twitch as a map, mapped by code. This can take a long time and transfer a lot of data (~a few MB). You really should cache this list, it isn't cached here on purpose to provide freedom to the dev
func (*TwitchKraken) GetEmoticons ¶
func (tk *TwitchKraken) GetEmoticons(emotesets []string) (resp *EmoteList, jsoerr *network.JSONError, err error)
GetEmoticons fetches a list of all! emotes on twitch. This can take a long time and transfer a lot of data (~a few MB). You really should cache this list, it isn't cached here on purpose to provide freedom to the dev
func (*TwitchKraken) GetGlobalCheeremotes ¶
func (tk *TwitchKraken) GetGlobalCheeremotes() (resp *Cheeremotes, jsoerr *network.JSONError, err error)
GetGlobalCheeremotes returns all cheeremotes that are accesible from every channel
func (*TwitchKraken) GetOauthToken ¶
func (tk *TwitchKraken) GetOauthToken(forceAuth bool, callbackURL, scopes string, callback func(token string)) (url string)
GetOauthToken starts an oauth grant process by starting a callback server on the callbackURL which will receive the token and returns the url which the user is required to open
func (*TwitchKraken) GetStream ¶
func (tk *TwitchKraken) GetStream(channelID, optType string) (resp *Stream, jsoerr *network.JSONError, err error)
GetStream gets information about a stream
func (*TwitchKraken) GetUserByName ¶
func (tk *TwitchKraken) GetUserByName(name string) (resp *Users, jsoerr *network.JSONError, err error)
GetUserByName returns a single user searched by name
func (*TwitchKraken) GetUsersByNames ¶
func (tk *TwitchKraken) GetUsersByNames(names []string) (resp *Users, jsoerr *network.JSONError, err error)
GetUsersByNames returns a list of users searched by their names
func (*TwitchKraken) IsSubscribedToChannel ¶
func (tk *TwitchKraken) IsSubscribedToChannel(oauth, channelID, userID string) (resp *Subscriber, jsoerr *network.JSONError, err error)
IsSubscribedToChannel checks if a specific user is subscribed to a channel
func (*TwitchKraken) IsUserFollowingChannel ¶
func (tk *TwitchKraken) IsUserFollowingChannel(userID, channelID string) (resp *Following, jsoerr *network.JSONError, err error)
IsUserFollowingChannel returns a relation if a specific user is following a channel
func (*TwitchKraken) RemoveChannelFromAllCommunites ¶
func (tk *TwitchKraken) RemoveChannelFromAllCommunites(oauth, channelID string) (jsoerr *network.JSONError, err error)
RemoveChannelFromAllCommunites remove a channel from all! communities it is part of
func (*TwitchKraken) ResetStreamkey ¶
func (tk *TwitchKraken) ResetStreamkey(oauth, channelID string) (resp *ChannelAuthenticated, jsoerr *network.JSONError, err error)
ResetStreamkey resets the streamkey
func (*TwitchKraken) RevokeToken ¶
func (tk *TwitchKraken) RevokeToken(oauth string)
RevokeToken revokes a previously granted oauth token
func (*TwitchKraken) RunCommercial ¶
func (tk *TwitchKraken) RunCommercial(oauth, channelID string, length *CommercialLength) (resp *CommercialResponse, jsoerr *network.JSONError, err error)
RunCommercial tries to run a commercial
func (*TwitchKraken) UpdateChannel ¶
func (tk *TwitchKraken) UpdateChannel(oauth, channelID string, data *ChannelUpdate) (resp *Channel, jsoerr *network.JSONError, err error)
UpdateChannel posts the data object to the API to update the selected channel
func (*TwitchKraken) ValidateToken ¶
func (tk *TwitchKraken) ValidateToken(oauth string) (resp *TokenValidation, jsoerr *network.JSONError, err error)
ValidateToken sends an oauth token to twitch api for validation
type User ¶
type User struct { ID json.Number `json:"_id"` Bio string `json:"bio"` CreatedAt time.Time `json:"created_at"` DisplayName string `json:"display_name"` Logo string `json:"logo"` Name string `json:"name"` Type string `json:"type"` UpdatedAt time.Time `json:"updated_at"` }
User contains information about a user
type Video ¶
type Video struct { ID json.Number `json:"_id"` BroadcastID json.Number `json:"broadcast_id"` BroadcastType string `json:"broadcast_type"` Channel struct { ID json.Number `json:"_id"` DisplayName string `json:"display_name"` Name string `json:"name"` } `json:"channel"` CreatedAt time.Time `json:"created_at"` Description string `json:"description"` DescriptionHTML string `json:"description_html"` Fps struct { Chunked float64 `json:"chunked"` High float64 `json:"high"` Low float64 `json:"low"` Medium float64 `json:"medium"` Mobile float64 `json:"mobile"` } `json:"fps"` Game string `json:"game"` Language string `json:"language"` Length int `json:"length"` Preview struct { Large string `json:"large"` Medium string `json:"medium"` Small string `json:"small"` Template string `json:"template"` } `json:"preview"` PublishedAt time.Time `json:"published_at"` Resolutions struct { Chunked string `json:"chunked"` High string `json:"high"` Low string `json:"low"` Medium string `json:"medium"` Mobile string `json:"mobile"` } `json:"resolutions"` Status string `json:"status"` TagList string `json:"tag_list"` Thumbnails struct { Large []struct { Type string `json:"type"` URL string `json:"url"` } `json:"large"` Medium []struct { Type string `json:"type"` URL string `json:"url"` } `json:"medium"` Small []struct { Type string `json:"type"` URL string `json:"url"` } `json:"small"` Template []struct { Type string `json:"type"` URL string `json:"url"` } `json:"template"` } `json:"thumbnails"` Title string `json:"title"` URL string `json:"url"` Viewable string `json:"viewable"` ViewableAt interface{} `json:"viewable_at"` Views int `json:"views"` }
Video contains information about a video