Documentation
¶
Index ¶
- Variables
- func DeleteSubscription(ctx context.Context, cl Client, tok *oauth2.Token, id string) error
- func Shards(ctx context.Context, client Client, tok *oauth2.Token, conduit, status string) iter.Seq2[Shard, error]
- func SubscribeConduit(ctx context.Context, client Client, tok *oauth2.Token, ...) (string, error)
- func Subscriptions(ctx context.Context, cl Client, tok *oauth2.Token, typ string) iter.Seq2[Subscription, error]
- type Client
- type Conduit
- func Conduits(ctx context.Context, client Client, tok *oauth2.Token) ([]Conduit, error)
- func CreateConduit(ctx context.Context, client Client, tok *oauth2.Token, shards int) (Conduit, error)
- func UpdateConduit(ctx context.Context, client Client, tok *oauth2.Token, conduit string, ...) (Conduit, error)
- type Shard
- type ShardTransport
- type ShardUpdate
- type Stream
- type Subscription
- type SubscriptionCondition
- type SubscriptionTransport
- type User
- type Validation
Constants ¶
This section is empty.
Variables ¶
var ErrNeedRefresh = errors.New("need refresh")
ErrNeedRefresh is an error indicating that the access token needs to be refreshed. It must be checked using errors.Is.
Functions ¶
func DeleteSubscription ¶
DeleteSubscription calls the Delete EventSub Subscription API to delete a subscription. Requires an app access token for webhook or conduit subscriptions or a user access token for WebSocket subscriptions.
func Shards ¶
func Shards(ctx context.Context, client Client, tok *oauth2.Token, conduit, status string) iter.Seq2[Shard, error]
Shards calls the Get Conduit Shards API to list a conduit's shards. Requires an app access token.
func SubscribeConduit ¶
func SubscribeConduit(ctx context.Context, client Client, tok *oauth2.Token, conduit, sub, version string, condition map[string]string) (string, error)
SubscribeConduit calls the Create EventSub Subscription API for a conduit. Requires an app access token.
func Subscriptions ¶
func Subscriptions(ctx context.Context, cl Client, tok *oauth2.Token, typ string) iter.Seq2[Subscription, error]
Subscriptions yields all EventSub subscriptions associated with a client of a given type. If typ is the empty string, all subscriptions are yielded. Requires an app access token for webhook or conduit subscriptions or a user access token for WebSocket subscriptions.
Types ¶
type Client ¶
type Client struct { // HTTP is the HTTP client for performing requests. // If nil, http.DefaultClient is used. HTTP *http.Client // ID is the application's client ID. ID string }
Client holds the context for requests to the Twitch API.
type Conduit ¶
Conduit is the EventSub API representation of a conduit.
func Conduits ¶
Conduits calls the Get Conduits API to list conduits owned by the client. Requires an app access token.
type Shard ¶
type Shard struct { ID int `json:"id,string"` Status string `json:"status,omitempty"` Transport *ShardTransport `json:"transport,omitempty"` Disconnected string `json:"disconnected_at,omitempty"` }
Shard is the EventSub API representation of a conduit shard.
type ShardTransport ¶
type ShardUpdate ¶
ShardUpdate describes a change to a shard's transport.
type Stream ¶
type Stream 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"` IsMature bool `json:"is_mature"` }
Stream is the response type from https://dev.twitch.tv/docs/api/reference/#get-streams.
func UserStreams ¶
func UserStreams(ctx context.Context, client Client, tok *oauth2.Token, streams []Stream) ([]Stream, error)
UserStreams gets stream information for a list of up to 100 users. For each stream in the given list, if the user ID is provided, then the query is made by user ID, and otherwise it is made by user login. (NOTE: the ID field is not used as input; only UserID.) Logins used to search are normalized to lower case. The result reuses the memory in streams, but may be of different length and in any order.
If a given stream has both an ID and a login, the ID is used and the login is replaced with the result from the API. If a stream has neither, it is ignored.
type Subscription ¶
type Subscription struct { ID string `json:"id"` Status string `json:"status"` Type string `json:"type"` Version string `json:"version"` Condition SubscriptionCondition `json:"condition"` Created string `json:"created_at"` Transport SubscriptionTransport `json:"transport"` Cost int `json:"cost"` }
type SubscriptionCondition ¶
type SubscriptionCondition struct { // Broadcaster is the broadcaster user ID for the condition. Broadcaster string `json:"broadcaster_user_id,omitempty"` // User is the user ID for the condition. User string `json:"user_id,omitempty"` // Extra holds any additional fields in the condition. Extra jsontext.Value `json:",unknown"` }
type SubscriptionTransport ¶
type SubscriptionTransport struct { Method string `json:"method"` Callback string `json:"callback,omitempty"` Session string `json:"session,omitempty"` Connected string `json:"connected_at,omitempty"` Disconnected string `json:"disconnected_at,omitempty"` Conduit string `json:"conduit_id,omitempty"` }
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"` CreatedAt string `json:"created_at"` }
User is the response type from https://dev.twitch.tv/docs/api/reference/#get-users.
func Users ¶
Users gets user information for a list of up to 100 users. For each user in the given list, if the ID is provided, then the query is made by ID, and otherwise it is made by login. Logins used to search are normalized to lower case. The result reuses the memory in users, but may be of different length.
If a given user has both an ID and a login, the ID is used and the login is replaced with the result from the API. If a user has neither, it is ignored.
type Validation ¶
type Validation struct { ClientID string `json:"client_id"` Login string `json:"login"` Scopes []string `json:"scopes"` UserID string `json:"user_id"` ExpiresIn int `json:"expires_in"` Message string `json:"message"` Status int `json:"status"` }
Validation describes an access token's validation status.
func Validate ¶
Validate checks the status of an access token. If the API response indicates that the access token is invalid, the returned error wraps ErrNeedRefresh. The returned Validation may be non-nil even if the error is also non-nil.