Documentation
¶
Index ¶
- Variables
- func ValidateToken(ctx context.Context, httpClient *http.Client, accessToken string) (bool, error)
- type API
- func (a *API) AddChannelModerator(ctx context.Context, broadcasterID string, userID string) error
- func (a *API) AddChannelVIP(ctx context.Context, broadcasterID string, userID string) error
- func (a *API) BanUser(ctx context.Context, broadcasterID string, moderatorID string, ...) error
- func (a *API) CancelRaid(ctx context.Context, broadcasterID string) error
- func (a *API) CreateClip(ctx context.Context, broadcastID string, hasDelay bool) (CreatedClip, error)
- func (a *API) CreateEventSubSubscription(ctx context.Context, reqData CreateEventSubSubscriptionRequest) (CreateEventSubSubscriptionResponse, error)
- func (a *API) CreateStreamMarker(ctx context.Context, req CreateStreamMarkerRequest) (StreamMarker, error)
- func (a *API) DeleteMessage(ctx context.Context, broadcasterID string, moderatorID string, ...) error
- func (a *API) DeleteSubSubscriptions(ctx context.Context, id string) error
- func (a *API) FetchAllUserEmotes(ctx context.Context, userID string, broadcasterID string) ([]UserEmoteImage, string, error)
- func (a *API) FetchEventSubSubscriptions(ctx context.Context, status, subType, userID string) ([]EventSubData, error)
- func (a *API) FetchUnbanRequests(ctx context.Context, broadcasterID, moderatorID string) ([]UnbanRequest, error)
- func (a *API) FetchUserFollowedChannels(ctx context.Context, userID string, broadcasterID string) ([]FollowedChannel, error)
- func (a *API) GetChannelChatBadges(ctx context.Context, broadcasterID string) ([]BadgeSet, error)
- func (a *API) GetChannelEmotes(ctx context.Context, broadcaster string) (EmoteResponse, error)
- func (a *API) GetChatSettings(ctx context.Context, broadcasterID string, moderatorID string) (GetChatSettingsResponse, error)
- func (a *API) GetGlobalChatBadges(ctx context.Context) ([]BadgeSet, error)
- func (a *API) GetGlobalEmotes(ctx context.Context) (EmoteResponse, error)
- func (a *API) GetModerators(ctx context.Context, broadcasterID string, userIDs []string) ([]ChatRoleUser, error)
- func (a *API) GetStreamInfo(ctx context.Context, broadcastID []string) (GetStreamsResponse, error)
- func (a *API) GetUserChatColor(ctx context.Context, userIDs []string) ([]UserChatColor, error)
- func (a *API) GetUsers(ctx context.Context, logins []string, ids []string) (UserResponse, error)
- func (a *API) GetVIPs(ctx context.Context, broadcasterID string, userIDs []string) ([]ChatRoleUser, error)
- func (a *API) ManageAutoModMessage(ctx context.Context, userID string, messageID string, action string) error
- func (a *API) RemoveChannelModerator(ctx context.Context, broadcasterID string, userID string) error
- func (a *API) RemoveChannelVIP(ctx context.Context, broadcasterID string, userID string) error
- func (a *API) ResolveBanRequest(ctx context.Context, ...) (UnbanRequest, error)
- func (a *API) SendChatAnnouncement(ctx context.Context, broadcasterID string, moderatorID string, ...) error
- func (a *API) SendChatMessage(ctx context.Context, data SendChatMessageRequest) (SendChatMessageResponse, error)
- func (a *API) SendShoutout(ctx context.Context, fromBroadcasterID string, toBroadcasterID string, ...) error
- func (a *API) SnoozeNextAd(ctx context.Context, broadcasterID string) (AdSnoozeData, error)
- func (a *API) StartRaid(ctx context.Context, fromBroadcasterID string, toBroadcasterID string) (RaidData, error)
- func (a *API) UnbanUser(ctx context.Context, broadcasterID string, moderatorID string, userID string) error
- func (a *API) UpdateChatSettings(ctx context.Context, broadcasterID string, moderatorID string, ...) (GetChatSettingsResponse, error)
- func (a *API) WarnChatUser(ctx context.Context, broadcasterID string, moderatorID string, userID string, ...) error
- type APIError
- type APIOptionFunc
- type AccountProvider
- type AdSnoozeData
- type BadgeSet
- type BadgeVersion
- type BanUserData
- type BanUserRequest
- type ChatAnnouncementColor
- type ChatRoleUser
- type ChatRoleUsersResponse
- type ChatSettingData
- type ChatSettingsUpdateData
- type CreateChatAnnouncementRequest
- type CreateClipResponse
- type CreateEventSubSubscriptionRequest
- type CreateEventSubSubscriptionResponse
- type CreateStreamMarkerRequest
- type CreateStreamMarkerResponse
- type CreatedClip
- type DropReason
- type EmoteData
- type EmoteImage
- type EmoteResponse
- type EventSubData
- type EventSubTransport
- type EventSubTransportRequest
- type FollowedChannel
- type GetChannelChatBadgesResp
- type GetChatSettingsResponse
- type GetEventSubSubscriptionsResponse
- type GetFollowedChannelsResponse
- type GetGlobalBadgesResp
- type GetStreamsResponse
- type GetUnbanRequestsResponse
- type GetUserChatColorResponse
- type GetUserEmotesResponse
- type ManageAutoModMessageRequest
- type Pagination
- type RaidData
- type SendChatMessageData
- type SendChatMessageRequest
- type SendChatMessageResponse
- type SnoozeNextAdResponse
- type StartRaidResponse
- type StreamData
- type StreamMarker
- type TokenRefresher
- type UnbanRequest
- type UserChatColor
- type UserData
- type UserEmoteImage
- type UserResponse
- type WarnChatUserData
- type WarnChatUserRequest
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoAuthProvided = errors.New("one of app secret or user access token needs to be provided") ErrNoUserAccess = errors.New("user endpoint called when no token was provided") ErrUserRefreshToken = errors.New("the provided user refresh token is empty") ErrNoRefresher = errors.New("refresher was not provided") )
Functions ¶
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
func (*API) AddChannelModerator ¶ added in v1.5.0
func (*API) AddChannelVIP ¶ added in v1.5.0
func (*API) CancelRaid ¶ added in v1.5.0
func (*API) CreateClip ¶
func (*API) CreateEventSubSubscription ¶
func (a *API) CreateEventSubSubscription(ctx context.Context, reqData CreateEventSubSubscriptionRequest) (CreateEventSubSubscriptionResponse, error)
func (*API) CreateStreamMarker ¶
func (a *API) CreateStreamMarker(ctx context.Context, req CreateStreamMarkerRequest) (StreamMarker, error)
func (*API) DeleteMessage ¶
func (*API) DeleteSubSubscriptions ¶
func (*API) FetchAllUserEmotes ¶
func (*API) FetchEventSubSubscriptions ¶
func (a *API) FetchEventSubSubscriptions(ctx context.Context, status, subType, userID string) ([]EventSubData, error)
https://dev.twitch.tv/docs/api/reference/#get-eventsub-subscriptions
func (*API) FetchUnbanRequests ¶
func (*API) FetchUserFollowedChannels ¶
func (*API) GetChannelChatBadges ¶
func (*API) GetChannelEmotes ¶
func (*API) GetChatSettings ¶
func (a *API) GetChatSettings(ctx context.Context, broadcasterID string, moderatorID string) (GetChatSettingsResponse, error)
moderatorID needs to match ID of the user the token was generated for
func (*API) GetGlobalChatBadges ¶
func (*API) GetGlobalEmotes ¶
func (a *API) GetGlobalEmotes(ctx context.Context) (EmoteResponse, error)
func (*API) GetModerators ¶ added in v1.5.0
func (a *API) GetModerators(ctx context.Context, broadcasterID string, userIDs []string) ([]ChatRoleUser, error)
GetModerators lists the channel's moderators. userIDs optionally filters the result to the given users, so callers can resolve specific roles without downloading every page.
func (*API) GetStreamInfo ¶
func (*API) GetUserChatColor ¶
func (*API) ManageAutoModMessage ¶ added in v1.5.0
func (*API) RemoveChannelModerator ¶ added in v1.5.0
func (*API) RemoveChannelVIP ¶ added in v1.5.0
func (*API) ResolveBanRequest ¶
func (a *API) ResolveBanRequest(ctx context.Context, broadcasterID, moderatorID, requestID, status, resolutionText string) (UnbanRequest, error)
ResolveBanRequest approves or denies one unban request. resolutionText is optional and limited to 500 characters by Twitch.
func (*API) SendChatAnnouncement ¶
func (*API) SendChatMessage ¶
func (a *API) SendChatMessage(ctx context.Context, data SendChatMessageRequest) (SendChatMessageResponse, error)
func (*API) SendShoutout ¶ added in v1.5.0
func (*API) SnoozeNextAd ¶ added in v1.5.0
func (*API) UpdateChatSettings ¶ added in v1.5.0
func (a *API) UpdateChatSettings(ctx context.Context, broadcasterID string, moderatorID string, data ChatSettingsUpdateData) (GetChatSettingsResponse, error)
type APIError ¶
type APIError struct {
ErrorText string `json:"error"`
Status int `json:"status"`
Message string `json:"message"`
}
error response
type APIOptionFunc ¶
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) APIOptionFunc
func WithTransport ¶ added in v0.7.0
func WithTransport(transport http.RoundTripper) APIOptionFunc
func WithUserAuthentication ¶
func WithUserAuthentication(provider AccountProvider, refresher TokenRefresher, accountID string) APIOptionFunc
type AccountProvider ¶
type AdSnoozeData ¶ added in v1.5.0
type BadgeSet ¶
type BadgeSet struct {
ID string `json:"set_id"`
Versions []BadgeVersion `json:"versions"`
}
https://dev.twitch.tv/docs/api/reference/#get-channel-chat-badges https://dev.twitch.tv/docs/api/reference#get-global-emotes
type BadgeVersion ¶
type BadgeVersion struct {
ID string `json:"id"`
Image_URL_1x string `json:"image_url_1x"`
Image_URL_2x string `json:"image_url_2x"`
Image_URL_4x string `json:"image_url_4x"`
Title string `json:"title"`
Description string `json:"description"`
ClickAction string `json:"click_action"`
ClickURL string `json:"click_url"`
}
https://dev.twitch.tv/docs/api/reference/#get-channel-chat-badges https://dev.twitch.tv/docs/api/reference#get-global-emotes
type BanUserData ¶
type BanUserRequest ¶
type BanUserRequest struct {
Data BanUserData `json:"data"`
}
type ChatAnnouncementColor ¶
type ChatAnnouncementColor string
const ( ChatAnnouncementColorBlue ChatAnnouncementColor = "blue" ChatAnnouncementColorGreen ChatAnnouncementColor = "green" ChatAnnouncementColorOrange ChatAnnouncementColor = "orange" ChatAnnouncementColorPurple ChatAnnouncementColor = "purple" ChatAnnouncementColorPrimary ChatAnnouncementColor = "primary" )
type ChatRoleUser ¶ added in v1.5.0
type ChatRoleUser struct {
UserID string `json:"user_id"`
UserLogin string `json:"user_login"`
UserName string `json:"user_name"`
}
https://dev.twitch.tv/docs/api/reference/#get-moderators https://dev.twitch.tv/docs/api/reference/#get-vips
type ChatRoleUsersResponse ¶ added in v1.5.0
type ChatRoleUsersResponse struct {
Data []ChatRoleUser `json:"data"`
Pagination Pagination `json:"pagination"`
}
https://dev.twitch.tv/docs/api/reference/#get-moderators https://dev.twitch.tv/docs/api/reference/#get-vips
type ChatSettingData ¶
type ChatSettingData struct {
BroadcasterID string `json:"broadcaster_id"`
SlowMode bool `json:"slow_mode"`
SlowModeWaitTime int `json:"slow_mode_wait_time"` // in seconds
FollowerMode bool `json:"follower_mode"`
FollowerModeDuration int `json:"follower_mode_duration"` // in minutes
SubscriberMode bool `json:"subscriber_mode"`
EmoteMode bool `json:"emote_mode"`
UniqueChatMode bool `json:"unique_chat_mode"`
NonModeratorChatDelay bool `json:"non_moderator_chat_delay"`
NonModeratorChatDelayDuration int `json:"non_moderator_chat_delay_duration"` // in seconds
}
type ChatSettingsUpdateData ¶ added in v1.5.0
type ChatSettingsUpdateData struct {
SlowMode *bool `json:"slow_mode,omitempty"`
SlowModeWaitTime *int `json:"slow_mode_wait_time,omitempty"`
FollowerMode *bool `json:"follower_mode,omitempty"`
FollowerModeDuration *int `json:"follower_mode_duration,omitempty"`
SubscriberMode *bool `json:"subscriber_mode,omitempty"`
EmoteMode *bool `json:"emote_mode,omitempty"`
UniqueChatMode *bool `json:"unique_chat_mode,omitempty"`
NonModeratorChatDelay *bool `json:"non_moderator_chat_delay,omitempty"`
NonModeratorChatDelayDuration *int `json:"non_moderator_chat_delay_duration,omitempty"`
}
ChatSettingsUpdateData is the PATCH body of Update Chat Settings. Every field is optional: nil means "leave this setting alone", which is why the fields are pointers instead of zero values. A false boolean is a real update.
type CreateChatAnnouncementRequest ¶
type CreateChatAnnouncementRequest struct {
Message string `json:"message"`
Color ChatAnnouncementColor `json:"color"`
}
https://dev.twitch.tv/docs/api/reference/#send-chat-announcement
type CreateClipResponse ¶
type CreateClipResponse struct {
Data []CreatedClip `json:"data"`
}
type CreateEventSubSubscriptionRequest ¶
type CreateEventSubSubscriptionRequest struct {
Type string `json:"type"`
Version string `json:"version"`
Condition map[string]string `json:"condition"`
Transport EventSubTransportRequest `json:"transport"`
}
https://dev.twitch.tv/docs/api/reference/#create-eventsub-subscription
type CreateEventSubSubscriptionResponse ¶
type CreateEventSubSubscriptionResponse struct {
Data []EventSubData `json:"data"`
Total int `json:"total"`
TotalCost int `json:"total_cost"`
MaxTotalCost int `json:"max_total_cost"`
}
https://dev.twitch.tv/docs/api/reference/#create-eventsub-subscription
type CreateStreamMarkerRequest ¶
type CreateStreamMarkerRequest struct {
UserID string `json:"user_id"`
// optional
Description string `json:"description,omitempty"`
}
https://dev.twitch.tv/docs/api/reference/#create-stream-marker
type CreateStreamMarkerResponse ¶
type CreateStreamMarkerResponse struct {
Data []StreamMarker `json:"data"`
}
https://dev.twitch.tv/docs/api/reference/#create-stream-marker
type CreatedClip ¶
type DropReason ¶
type EmoteData ¶
type EmoteImage ¶
type EmoteResponse ¶
type EventSubData ¶
type EventSubData struct {
ID string `json:"id"`
Status string `json:"status"`
Type string `json:"type"`
Version string `json:"version"`
Condition map[string]string `json:"condition"`
CreatedAt time.Time `json:"created_at"`
Transport EventSubTransport `json:"transport"`
Cost int `json:"cost"`
}
https://dev.twitch.tv/docs/api/reference/#create-eventsub-subscription
type EventSubTransport ¶
type EventSubTransport struct {
Method string `json:"method"`
ConduitID string `json:"conduit_id"`
}
https://dev.twitch.tv/docs/api/reference/#create-eventsub-subscription
type EventSubTransportRequest ¶
type EventSubTransportRequest struct {
Method string `json:"method"`
Callback string `json:"callback"`
ConduitID string `json:"conduit_id"`
Secret string `json:"secret"`
SessionID string `json:"session_id"`
}
https://dev.twitch.tv/docs/api/reference/#create-eventsub-subscription
type FollowedChannel ¶
type FollowedChannel struct {
BroadcasterID string `json:"broadcaster_id"`
BroadcasterLogin string `json:"broadcaster_login"`
BroadcasterName string `json:"broadcaster_name"`
FollowedAt time.Time `json:"followed_at"`
}
https://dev.twitch.tv/docs/api/reference/#get-followed-channels
type GetChannelChatBadgesResp ¶
type GetChannelChatBadgesResp struct {
Data []BadgeSet `json:"data"`
}
https://dev.twitch.tv/docs/api/reference/#get-channel-chat-badges https://dev.twitch.tv/docs/api/reference#get-global-emotes
type GetChatSettingsResponse ¶
type GetChatSettingsResponse struct {
Data []ChatSettingData `json:"data"`
}
type GetEventSubSubscriptionsResponse ¶
type GetEventSubSubscriptionsResponse struct {
Total int `json:"total"`
TotalCost int `json:"total_cost"`
MaxTotalCost int `json:"max_total_cost"`
Pagination Pagination `json:"pagination"`
Data []EventSubData `json:"data"`
}
https://dev.twitch.tv/docs/api/reference/#get-eventsub-subscriptions
type GetFollowedChannelsResponse ¶
type GetFollowedChannelsResponse struct {
Total int `json:"total"`
Data []FollowedChannel `json:"data"`
Pagination Pagination `json:"pagination"`
}
https://dev.twitch.tv/docs/api/reference/#get-followed-channels
type GetGlobalBadgesResp ¶
type GetGlobalBadgesResp struct {
Data []BadgeSet `json:"data"`
}
https://dev.twitch.tv/docs/api/reference/#get-channel-chat-badges https://dev.twitch.tv/docs/api/reference#get-global-emotes
type GetStreamsResponse ¶
type GetStreamsResponse struct {
Data []StreamData `json:"data"`
Pagination Pagination `json:"pagination"`
}
type GetUnbanRequestsResponse ¶
type GetUnbanRequestsResponse struct {
Data []UnbanRequest `json:"data"`
Pagination Pagination `json:"pagination"`
}
https://dev.twitch.tv/docs/api/reference/#get-unban-requests
type GetUserChatColorResponse ¶
type GetUserChatColorResponse struct {
Data []UserChatColor `json:"data"`
}
https://dev.twitch.tv/docs/api/reference/#get-user-chat-color
type GetUserEmotesResponse ¶
type GetUserEmotesResponse struct {
Data []UserEmoteImage `json:"data"`
Template string `json:"template"`
Pagination Pagination `json:"pagination"`
}
type ManageAutoModMessageRequest ¶ added in v1.5.0
type ManageAutoModMessageRequest struct {
UserID string `json:"user_id"`
MsgID string `json:"msg_id"`
Action string `json:"action"`
}
https://dev.twitch.tv/docs/api/reference/#manage-held-automod-messages
type Pagination ¶
type Pagination struct {
Cursor string `json:"cursor"`
}
type SendChatMessageData ¶
type SendChatMessageData struct {
MessageID string `json:"message_id"`
IsSent bool `json:"is_sent"`
DropReason DropReason `json:"drop_reason"`
}
type SendChatMessageRequest ¶
type SendChatMessageResponse ¶
type SendChatMessageResponse struct {
Data []SendChatMessageData `json:"data"`
}
type SnoozeNextAdResponse ¶ added in v1.5.0
type SnoozeNextAdResponse struct {
Data []AdSnoozeData `json:"data"`
}
type StartRaidResponse ¶ added in v1.5.0
type StartRaidResponse struct {
Data []RaidData `json:"data"`
}
type StreamData ¶
type StreamData struct {
ID string `json:"id"`
UserID string `json:"user_id"`
UserLogin string `json:"user_login"`
UserName string `json:"user_name"`
GameID string `json:"game_id"`
GameName string `json:"game_name"`
Type string `json:"type"`
Title string `json:"title"`
Tags []string `json:"tags"`
ViewerCount int `json:"viewer_count"`
StartedAt time.Time `json:"started_at"`
Language string `json:"language"`
ThumbnailURL string `json:"thumbnail_url"`
TagIds []any `json:"tag_ids"`
IsMature bool `json:"is_mature"`
}
type StreamMarker ¶
type StreamMarker struct {
ID string `json:"id"`
CreatedAt time.Time `json:"created_at"`
PositionSeconds int `json:"position_seconds"`
Description string `json:"description"`
}
https://dev.twitch.tv/docs/api/reference/#create-stream-marker
type TokenRefresher ¶
type UnbanRequest ¶
type UnbanRequest struct {
ID string `json:"id"`
BroadcasterName string `json:"broadcaster_name"`
BroadcasterLogin string `json:"broadcaster_login"`
BroadcasterID string `json:"broadcaster_id"`
ModeratorID string `json:"moderator_id"`
ModeratorLogin string `json:"moderator_login"`
ModeratorName string `json:"moderator_name"`
UserID string `json:"user_id"`
UserLogin string `json:"user_login"`
UserName string `json:"user_name"`
Text string `json:"text"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
ResolvedAt time.Time `json:"resolved_at"`
ResolutionText string `json:"resolution_text"`
}
https://dev.twitch.tv/docs/api/reference/#get-unban-requests
type UserChatColor ¶
type UserChatColor struct {
Color string `json:"color"`
UserName string `json:"user_name"`
UserLogin string `json:"user_login"`
UserID string `json:"user_id"`
}
https://dev.twitch.tv/docs/api/reference/#get-user-chat-color
type UserData ¶
type UserData 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"`
CreatedAt time.Time `json:"created_at"`
}
type UserEmoteImage ¶
type UserResponse ¶
type UserResponse struct {
Data []UserData `json:"data"`
}
type WarnChatUserData ¶ added in v1.5.0
type WarnChatUserRequest ¶ added in v1.5.0
type WarnChatUserRequest struct {
Data WarnChatUserData `json:"data"`
}