### Install Helix API Source: https://github.com/nicklaw5/helix/blob/main/docs/README.md Install the Helix API library using go get. This command fetches the latest version of the library. ```shell go get -u github.com/nicklaw5/helix/v2 ``` -------------------------------- ### Get Polls Source: https://github.com/nicklaw5/helix/blob/main/docs/polls_docs.md Example of how to retrieve polls for a broadcaster. Ensure the helix client is initialized with your client ID. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetPolls(&helix.PollsParams{ BroadcasterID: "145328278", }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Users with Helix API Source: https://github.com/nicklaw5/helix/blob/main/docs/README.md Fetch user information using the GetUsers method, providing user IDs and/or logins. This example demonstrates how to retrieve user data and access response metadata like status code and rate limits. ```go resp, err := client.GetUsers(&helix.UsersParams{ IDs: []string{"26301881", "18074328"}, Logins: []string{"summit1g", "lirik"}, }) if err != nil { panic(err) } fmt.Printf("Status code: %d\n", resp.StatusCode) fmt.Printf("Rate limit: %d\n", resp.GetRateLimit()) fmt.Printf("Rate limit remaining: %d\n", resp.GetRateLimitRemaining()) fmt.Printf("Rate limit reset: %d\n\n", resp.GetRateLimitReset()) for _, user := range resp.Data.Users { fmt.Printf("ID: %s Name: %s\n", user.ID, user.DisplayName) } ``` -------------------------------- ### Get Stream Markers Source: https://github.com/nicklaw5/helix/blob/main/docs/stream_markers_docs.md Retrieve stream markers for a VOD or a recorded livestream. This example fetches the first two stream markers for a specific VOD. The authenticated user requires the 'user:read:broadcast' scope. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", UserAccessToken: "your-user-access-token", }) if err != nil { // handle error } resp, err := client.GetStreamMarkers(&helix.StreamMarkersParams{ First: 2, VideoID: "123", }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Create Poll Source: https://github.com/nicklaw5/helix/blob/main/docs/polls_docs.md Example of how to create a new poll. Requires broadcaster ID, poll title, choices, and duration. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.CreatePoll(&helix.CreatePollParams{ BroadcasterID: "145328278", Title: "Test", Choices: []helix.PollChoiceParam{ helix.PollChoiceParam{ Title: "choice 1" }, helix.PollChoiceParam{ Title: "choice 2" }, }, Duration: 30, }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Users Follows Source: https://github.com/nicklaw5/helix/blob/main/docs/users_docs.md Retrieve the list of users followed by a specific user, identified by their `FromID`. ```Go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetUsersFollows(&helix.UsersFollowsParams{ FromID: "23161357", }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Games by Name Source: https://github.com/nicklaw5/helix/blob/main/docs/games_docs.md Retrieves game information by providing a list of game names. Requires client initialization with a ClientID. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetGames(&helix.GamesParams{ Names: []string{"Sea of Thieves", "Fortnite"}, }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Start a Raid Source: https://github.com/nicklaw5/helix/blob/main/docs/raid_docs.md Use this snippet to initiate a raid from one broadcaster to another. Ensure you have a valid Helix client initialized with your ClientID. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.StartRaid(&helix.StartRaidParams{ FromBroadcasterID: "22484632", ToBroadcasterID: "71092938" }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Webhook Subscriptions Source: https://github.com/nicklaw5/helix/blob/main/docs/webhook_docs.md Retrieves a list of webhook subscriptions. Requires client initialization with authentication tokens. ```Go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", AppAccessToken: "your-app-access-token", }) if err != nil { // handle error } resp, err := client.GetWebhookSubscriptions(&helix.WebhookSubscriptionsParams{ First: 10, }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Create Prediction Source: https://github.com/nicklaw5/helix/blob/main/docs/predictions_docs.md This example demonstrates how to create a new prediction. You must provide a title, at least two outcome choices, and a prediction window duration. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.CreatePrediction(&helix.CreatePredictionParams{ BroadcasterID: "145328278", Title: "Test", Outcomes: []helix.PredictionChoiceParam{ helix.PredictionChoiceParam{ Title: "choice 1" }, helix.PredictionChoiceParam{ Title: "choice 2" }, }, PredictionWindow: 300, }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Users Follows Source: https://github.com/nicklaw5/helix/blob/main/docs/users_docs.md Retrieves the follow relationships for a given user. ```APIDOC ## Get Users Follows ### Description Retrieves the list of users that a specific user follows. ### Method GET (implied by client.GetUsersFollows) ### Endpoint Not explicitly defined, but related to user follows. ### Parameters #### Query Parameters - **FromID** (string) - Required - The ID of the user whose follows are being requested. ### Request Example ```go client.GetUsersFollows(&helix.UsersFollowsParams{ FromID: "23161357", }) ``` ### Response #### Success Response (200) Details about the users being followed. #### Response Example ```go %+v ``` ``` -------------------------------- ### Get User Extensions Source: https://github.com/nicklaw5/helix/blob/main/docs/user_extensions.md Retrieves all user extensions for the authenticated user. Requires a ClientID and UserAccessToken. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", UserAccessToken: "user-access-token", }) if err != nil { // handle error } resp, err := client.GetUserExtensions() if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Raids Endpoints Source: https://github.com/nicklaw5/helix/blob/main/SUPPORTED_ENDPOINTS.md Endpoints for starting and canceling raids. ```APIDOC ## Raids ### Description Endpoints for managing raids. ### Endpoints - Start a Raid - Cancel a Raid ``` -------------------------------- ### Get Drops Entitlements Filtered by Fulfillment Status Source: https://github.com/nicklaw5/helix/blob/main/docs/drops_docs.md Retrieve entitlements for a specific user that match a given fulfillment status. The status 'CLAIMED' is used as an example. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetDropsEntitlements(&helix.GetDropEntitlementsParams{ UserID: "your-game-id", FulfillmentStatus: "CLAIMED" }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Streams Source: https://github.com/nicklaw5/helix/blob/main/docs/streams_docs.md Retrieves a list of streams. Specify parameters like the number of results and language. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetStreams(&helix.StreamsParams{ First: 10, Language: []string{"en"}, }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Videos Source: https://github.com/nicklaw5/helix/blob/main/docs/videos_docs.md Retrieves a list of videos based on specified parameters like GameID, Period, Type, Sort, and the number of results. Ensure the client is initialized with a valid ClientID. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetVideos(&helix.VideosParams{ GameID: "21779", Period: "month", Type: "highlight", Sort: "views", First: 10, }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Predictions Source: https://github.com/nicklaw5/helix/blob/main/docs/predictions_docs.md Use this snippet to retrieve a list of predictions for a given broadcaster. Ensure the client is initialized with valid options. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetPredictions(&helix.PredictionsParams{ BroadcasterID: "145328278", }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get EventSub Subscriptions Source: https://github.com/nicklaw5/helix/blob/main/docs/eventsub_docs.md Retrieves a list of enabled EventSub subscriptions. Ensure you have initialized the Helix client with your credentials. ```Go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", AppAccessToken: "your-app-access-token", }) if err != nil { // handle error } resp, err := client.GetEventSubSubscriptions(&helix.EventSubSubscriptionsParams{ Status: helix.EventSubStatusEnabled, // This is optional. }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Users by IDs or Logins Source: https://github.com/nicklaw5/helix/blob/main/docs/users_docs.md Retrieve user information using either a list of user IDs or a list of login names. Ensure you provide either IDs or Logins, but not both. ```Go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetUsers(&helix.UsersParams{ IDs: []string{"26301881", "18074328"}, Logins: []string{"summit1g", "lirik"}, }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Multiple Clips by IDs Source: https://github.com/nicklaw5/helix/blob/main/docs/clips_docs.md Retrieve multiple clips by providing a slice of clip IDs. Ensure the client is initialized with necessary options. ```Go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetClips(&helix.ClipsParams{ IDs: []string{"EncouragingPluckySlothSSSsss", "PatientBlindingChamoisSmoocherZ"}, }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Followed Streams Source: https://github.com/nicklaw5/helix/blob/main/docs/streams_docs.md Retrieves a list of streams that a specific user is following. Requires the UserID. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetFollowedStream(&helix.FollowedStreamsParams{ UserID: "123456", }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Top Games Source: https://github.com/nicklaw5/helix/blob/main/docs/games_docs.md Retrieves a list of top-selling games, specifying the number of results. Requires client initialization with a ClientID. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetTopGames(&helix.TopGamesParams{ First: 20, }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Global Emotes Source: https://github.com/nicklaw5/helix/blob/main/docs/chat_docs.md Retrieve all available global emotes. Requires a client with a ClientID. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetGlobalEmotes() if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get User Block List Source: https://github.com/nicklaw5/helix/blob/main/docs/users_docs.md Retrieves a list of users that a broadcaster has blocked. ```APIDOC ## Get User Block List ### Description Retrieves the list of users blocked by a specific broadcaster. ### Method GET (implied by client.GetUsersBlocked) ### Endpoint Not explicitly defined, but related to user blocks. ### Parameters #### Query Parameters - **BroadcasterID** (string) - Required - The ID of the broadcaster whose block list is being requested. ### Request Example ```go client.GetUsersBlocked(&helix.UsersBlockedParams{ BroadcasterID: "145328278", }) ``` ### Response #### Success Response (200) Details about the blocked users. #### Response Example ```go %+v ``` ``` -------------------------------- ### Get Channel Information Source: https://github.com/nicklaw5/helix/blob/main/docs/channels_docs.md Retrieve information about a specific channel using its BroadcasterID. ```Go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetChannelInformation(&helix.GetChannelInformationParams{ BroadcasterID: "123456", }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Emote Sets Source: https://github.com/nicklaw5/helix/blob/main/docs/chat_docs.md Retrieve a specific set of emotes by their IDs. Requires a client with a ClientID. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetEmoteSets(&helix.GetEmoteSetsParams{ EmoteSetIDs: []string{"300678379"}, }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Global Chat Badges Source: https://github.com/nicklaw5/helix/blob/main/docs/chat_docs.md Retrieve all available global chat badges. Requires a client with a ClientID. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetGlobalChatBadges() if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get User Block List Source: https://github.com/nicklaw5/helix/blob/main/docs/users_docs.md Retrieve a list of users blocked by a specific broadcaster, identified by `BroadcasterID`. ```Go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetUsersBlocked(&helix.UsersBlockedParams{ BroadcasterID: "145328278", }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Clips by Broadcaster ID Source: https://github.com/nicklaw5/helix/blob/main/docs/clips_docs.md Fetch clips associated with a specific broadcaster using their ID. The client must be properly initialized. ```Go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetClips(&helix.ClipsParams{ BroadcasterID: "26490481", // summit1g }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Users Source: https://github.com/nicklaw5/helix/blob/main/docs/users_docs.md Retrieves user information. You can specify users by their IDs or by their login names. Providing both IDs and logins is not necessary; one or the other will suffice. ```APIDOC ## Get Users ### Description Retrieves user information based on provided IDs or login names. ### Method GET (implied by client.GetUsers) ### Endpoint Not explicitly defined, but related to user retrieval. ### Parameters #### Query Parameters - **IDs** (array of string) - Required/Optional - A list of user IDs. - **Logins** (array of string) - Required/Optional - A list of user login names. *Note: Provide either IDs or Logins, not both.* ### Request Example ```go client.GetUsers(&helix.UsersParams{ IDs: []string{"26301881", "18074328"}, Logins: []string{"summit1g", "lirik"}, }) ``` ### Response #### Success Response (200) Details of the requested users. #### Response Example ```go %+v ``` ``` -------------------------------- ### Get Extension Configuration Segments Source: https://github.com/nicklaw5/helix/blob/main/docs/extensions_docs.md Retrieves configuration segments for a specific extension. This includes initializing the client, setting up authentication with JWT, and defining parameters for the configuration request. ```APIDOC ## Get Extension Configuration Segments ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", UserAccessToken: "your-user-access-token", ExtensionOpts: helix.ExtensionOptions{ OwnerUserID: os.Getenv("EXT_OWNER_ID"), Secret: os.Getenv("EXT_SECRET"), ConfigurationVersion: os.Getenv("EXT_CFG_VERSION"), Version: os.Getenv("EXT_VERSION"), }, }) if err != nil { // handle error } claims, err := client.ExtensionCreateClaims(broadcasterID, ExternalRole, FormBroadcastSendPubSubPermissions(), 0) if err != nil { // handle error } // Set the JWT token to be used as in the Auth bearer header. jwt := client.ExtensionJWTSign(claims) client.SetExtensionSignedJWTToken(jwt) params := helix.ExtensionGetConfigurationParams{ ExtensionID: "some-extension-id", // Required Segments: []helix.ExtensionSegmentType{helix.GlobalSegment}, // Optional } resp, err := client.GetExtensionConfigurationSegment if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` ``` -------------------------------- ### Get Clips by Game ID Source: https://github.com/nicklaw5/helix/blob/main/docs/clips_docs.md Retrieve clips for a particular game by specifying the Game ID. Ensure the Helix client is initialized. ```Go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetClips(&helix.ClipsParams{ GameID: "490377", // Sea of Thieves }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Drops Entitlements for a Game Source: https://github.com/nicklaw5/helix/blob/main/docs/drops_docs.md Retrieve entitlement information for all users of a specific game. Requires a valid ClientID and GameID. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetDropsEntitlements(&helix.GetDropEntitlementsParams{ GameID: "your-game-id", }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Update a Custom Reward Source: https://github.com/nicklaw5/helix/blob/main/docs/channels_points_docs.md This example demonstrates how to update an existing custom reward on a Twitch channel. Provide the reward ID and broadcaster ID along with the fields to modify. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.UpdateCustomReward(&helix.UpdateChannelCustomRewardsParams{ ID : "6741db51-bc4e-4f0e-b96b-d79eafe227f3", BroadcasterID : "145328278", Title : "game analysis 1v1", Cost : 50000, }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Channel Chat Badges Source: https://github.com/nicklaw5/helix/blob/main/docs/chat_docs.md Retrieve chat badges for a specific broadcaster. Requires a client with a ClientID. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetChannelChatBadges(&helix.GetChatBadgeParams{ BroadcasterID: "145328278", }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Extension Analytics Source: https://github.com/nicklaw5/helix/blob/main/docs/analytics_docs.md Fetches analytics data for a specific extension. Requires client initialization and parameters specifying the extension ID and type. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", UserAccessToken: "your-user-access-token", }) if err != nil { // handle error } params := helix.ExtensionAnalyticsParams{ ExtensionID: "abcd", Type: "overview_v1", } resp, err := client.GetExtensionAnalytics(¶ms) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Drops Entitlements for a User Source: https://github.com/nicklaw5/helix/blob/main/docs/drops_docs.md Retrieve entitlement information for a specific user. Requires a valid ClientID and UserID. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetDropsEntitlements(&helix.GetDropEntitlementsParams{ UserID: "your-game-id", }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Extension Configuration Segment Source: https://github.com/nicklaw5/helix/blob/main/docs/extensions_docs.md Initializes a Helix client, creates an extension JWT, and retrieves a specific configuration segment for an extension. Ensure the JWT is set on the client before making the request. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", UserAccessToken: "your-user-access-token", ExtensionOpts: helix.ExtensionOptions{ OwnerUserID: os.Getenv("EXT_OWNER_ID"), Secret: os.Getenv("EXT_SECRET"), ConfigurationVersion: os.Getenv("EXT_CFG_VERSION"), Version: os.Getenv("EXT_VERSION"), }, }) if err != nil { // handle error } claims, err := client.ExtensionCreateClaims(broadcasterID, ExternalRole, FormBroadcastSendPubSubPermissions(), 0) if err != nil { // handle error } // Set the JWT token to be used as in the Auth bearer header. jwt := client.ExtensionJWTSign(claims) client.SetExtensionSignedJWTToken(jwt) params := helix.ExtensionGetConfigurationParams{ ExtensionID: "some-extension-id", // Required Segments: []helix.ExtensionSegmentType{helix.GlobalSegment}, // Optional } resp, err := client.GetExtensionConfigurationSegment if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Handle EventSub Notification Source: https://github.com/nicklaw5/helix/blob/main/docs/eventsub_docs.md Processes incoming EventSub notifications, verifies the signature using a shared secret, and handles challenge requests. This example specifically handles channel follow events. ```Go type eventSubNotification struct { Subscription helix.EventSubSubscription `json:"subscription"` Challenge string `json:"challenge"` Event json.RawMessage `json:"event"` } func eventsubFollow(w http.ResponseWriter, r *http.Request) { body, err := io.ReadAll(r.Body) if err != nil { log.Println(err) return } defer r.Body.Close() // verify that the notification came from twitch using the secret. if !helix.VerifyEventSubNotification("s3cre7w0rd", r.Header, string(body)) { log.Println("no valid signature on subscription") return } else { log.Println("verified signature for subscription") } var vals eventSubNotification err = json.NewDecoder(bytes.NewReader(body)).Decode(&vals) if err != nil { log.Println(err) return } // if there's a challenge in the request, respond with only the challenge to verify your eventsub. if vals.Challenge != "" { w.Write([]byte(vals.Challenge)) return } var followEvent helix.EventSubChannelFollowEvent err = json.NewDecoder(bytes.NewReader(vals.Event)).Decode(&followEvent) log.Printf("got follow webhook: %s follows %s\n", followEvent.UserName, followEvent.BroadcasterUserName) w.WriteHeader(200) w.Write([]byte("ok")) } ``` -------------------------------- ### Get Game Analytics CSV Source: https://github.com/nicklaw5/helix/blob/main/docs/analytics_docs.md Retrieves the downloadable CSV file containing game analytics data. Requires client initialization with authentication tokens. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", UserAccessToken: "your-user-access-token", }) if err != nil { // handle error } gameID := "493057" resp, err := client.GetGameAnalytics(gameID) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Bits Leaderboard Source: https://github.com/nicklaw5/helix/blob/main/docs/bits_docs.md Retrieves the top 20 Bits contributors over the past week. Ensure you have initialized the Helix client with valid credentials. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", UserAccessToken: "your-user-access-token", }) if err != nil { // handle error } resp, err := client.GetBitsLeaderboard(&helix.BitsLeaderboardParams{ Count: 20, Period: "week", }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get User Active Extensions (UserAccessToken) Source: https://github.com/nicklaw5/helix/blob/main/docs/user_extensions.md Retrieves the currently active user extensions using a User Access Token. Requires ClientID and UserAccessToken. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", UserAccessToken: "user-access-token", }) if err != nil { // handle error } resp, err := client.GetUserActiveExtensions(nil) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Webhook Subscriptions Source: https://github.com/nicklaw5/helix/blob/main/docs/webhook_docs.md Retrieves a list of webhook subscriptions. This operation allows you to fetch existing subscriptions based on specified parameters. ```APIDOC ## Get Webhook Subscriptions ### Description Retrieves a list of webhook subscriptions. This operation allows you to fetch existing subscriptions based on specified parameters. ### Method GET ### Endpoint /webhooks/subscriptions ### Parameters #### Query Parameters - **first** (integer) - Optional - The number of results to return per page. Maximum is 100. - **after** (string) - Optional - The cursor for the next page of results. ### Request Example ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", AppAccessToken: "your-app-access-token", }) if err != nil { // handle error } resp, err := client.GetWebhookSubscriptions(&helix.WebhookSubscriptionsParams{ First: 10, }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` ### Response #### Success Response (200) - **data** (array) - A list of webhook subscription objects. - **id** (string) - The ID of the subscription. - **status** (string) - The status of the subscription. - **version** (string) - The version of the webhook. - **type** (string) - The type of the event the subscription is for. - **condition** (object) - The condition for the subscription. - **transport** (object) - The transport details for the subscription. - **method** (string) - The HTTP method for the transport. - **callback_url** (string) - The URL to send notifications to. - **pagination** (object) - Pagination information. - **cursor** (string) - The cursor for the next page of results. #### Response Example ```json { "data": [ { "id": "12345", "status": "enabled", "version": "1", "type": "stream.online", "condition": {}, "transport": { "method": "POST", "callback_url": "https://example.com/webhook" } } ], "pagination": { "cursor": "abcde" } } ``` ``` -------------------------------- ### Get Broadcaster Subscriptions Source: https://github.com/nicklaw5/helix/blob/main/docs/subscriptions_docs.md Use this snippet to retrieve a list of all subscribers for a given broadcaster. Ensure you have initialized the Helix client with valid credentials. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", UserAccessToken: "your-user-access-token", }) if err != nil { // handle error } resp, err := client.GetSubscriptions(&helix.SubscriptionsParams{ BroadcasterID: "29776980", }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get Chat Settings Source: https://github.com/nicklaw5/helix/blob/main/docs/chat_docs.md Retrieve chat settings for a broadcaster. Requires a client with a ClientID and an AppAccessToken. A moderator token can provide additional settings. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", AppAccessToken: "your-app-user-token", // Optionally, a moderator's user token with the `moderator:read:chat_settings` scope can be specified to read some more settings }) if err != nil { // handle error } resp, err := client.GetChatSettings(&helix.GetChatSettingsParams{ BroadcasterID: "22484632", // ModeratorID should be specified matching the UserAccessToken if you want the extended information }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Initialize Client with Access Tokens (Options) Source: https://github.com/nicklaw5/helix/blob/main/docs/README.md Initializes the Helix client by providing all three types of access tokens (User, App, Device) directly in the options. Note that User access tokens are prioritized. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", UserAccessToken: "your-user-access-token", AppAccessToken: "your-app-access-token", DeviceAccessToken: "your-device-access-token" }) if err != nil { // handle error } // send API request... ``` -------------------------------- ### Get User Active Extensions (UserID) Source: https://github.com/nicklaw5/helix/blob/main/docs/user_extensions.md Retrieves active user extensions for a specific user ID. Requires ClientID and a UserActiveExtensionsParams struct with UserID set. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetUserActiveExtensions(&helix.UserActiveExtensionsParams{ UserID: "user-id" }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Set Access Tokens (Methods) Source: https://github.com/nicklaw5/helix/blob/main/docs/README.md Initializes the Helix client and then sets the User, App, and Device access tokens using separate methods. This approach is an alternative to providing them in the options. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } client.SetUserAccessToken("your-user-access-token") client.SetAppAccessToken("your-app-access-token") client.SetDeviceAccessToken("your-device-access-token") // send API request... ``` -------------------------------- ### Get User Chat Color Source: https://github.com/nicklaw5/helix/blob/main/docs/chat_docs.md Gets the color used for a user's name in chat. Requires UserID. ```APIDOC ## Get User Chat Color ### Description Gets the color used for the user’s name in chat. ### Method GET (Assumed based on function name and typical API patterns) ### Endpoint `/chat/color` (Assumed based on function name and typical API patterns) ### Parameters #### Query Parameters - **user_id** (string) - Required - The ID of the user whose chat color is being requested. ### Request Example ```json { "user_id": "22484632" } ``` ### Response #### Success Response (200) - (Structure not provided in source, but typically contains the user's chat color) #### Response Example ```json { "data": [ { "user_id": "22484632", "user_name": "example_user", "color": "#FF0000" } ] } ``` ``` -------------------------------- ### Get Drops Entitlements with Pagination Source: https://github.com/nicklaw5/helix/blob/main/docs/drops_docs.md Retrieve entitlement results across multiple pages. Use the 'After' cursor from the previous response to fetch the next set of results. Supports specifying the number of results per page with 'First'. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } // First page resp, err := client.GetDropsEntitlements(&helix.GetDropEntitlementsParams{ GameID: "your-game-id", After: "", First: 50, }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) // Next page resp, err = client.GetDropsEntitlements(&helix.GetDropEntitlementsParams{ GameID: "your-game-id", After: resp.Data.Pagination.Cursor, First: 50, }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Generate PUBSUB JWT Permissions Source: https://github.com/nicklaw5/helix/blob/main/docs/extensions_docs.md This section details how to form different types of PUBSUB JWT permissions required for publishing messages. It shows examples for broadcast, global, and whisper types. ```APIDOC ## Generate PUBSUB JWT Permissions Relevant PUBSUB permission must be passed to the 'ExtensionCreateClaims()' func, in order to correctly publish a pubsub message of a particular type. ### Broadcast pubsub type ```go client.FormBroadcastSendPubSubPermissions() ``` ### Global pubsub type ```go perms := client.FormGlobalSendPubSubPermissions() ``` ### Whisper User type ```go client.FormWhisperSendPubSubPermissions(userId) ``` ``` -------------------------------- ### Get Channel VIPs Source: https://github.com/nicklaw5/helix/blob/main/docs/vips_docs.md Retrieves a list of VIPs for a given broadcaster. Requires a user access token with the `channel:read:vips` scope and the `BroadcasterID` must match the token's user ID. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", UserAccessToken: "your-user-access-token", }) if err != nil { // handle error } resp, err := client.GetChannelVips(&helix.GetChannelVipsParams{ BroadcasterID: "54946241", }}) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Create a Clip Source: https://github.com/nicklaw5/helix/blob/main/docs/clips_docs.md Create a new clip for a specified broadcaster. This requires both ClientID and UserAccessToken for authentication. An optional delay can be applied. ```Go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", UserAccessToken: "your-user-acceess-token", }) if err != nil { // handle error } resp, err := client.CreateClip(&helix.CreateClipParams{ BroadcasterID: "26490481", // summit1g HasDelay: true, // optional, defaults to false }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ``` -------------------------------- ### Get VIPs Source: https://github.com/nicklaw5/helix/blob/main/docs/vips_docs.md Gets a list of the broadcaster’s VIPs. Requires a user access token with the `channel:read:vips` scope. `BroadcasterID` is required and must match the user ID of the access token. ```APIDOC ## Get VIPs ### Description Gets a list of the broadcaster’s VIPs. ### Method GET ### Endpoint `/channels/{broadcaster_id}/vips` ### Parameters #### Path Parameters - **broadcaster_id** (string) - Required - The ID of the broadcaster whose VIPs are to be retrieved. #### Query Parameters - **user_id** (string) - Required - The ID of the user to retrieve VIP information for. #### Request Body None ### Response #### Success Response (200) - **data** (array) - A list of VIP objects. - **user_id** (string) - The ID of the VIP user. - **user_login** (string) - The login name of the VIP user. - **user_name** (string) - The display name of the VIP user. - **pagination** (object) - Information for fetching the next page of results. - **cursor** (string) - The cursor for the next page of results. #### Response Example ```json { "data": [ { "user_id": "12345", "user_login": "vipuser1", "user_name": "VipUserOne" } ], "pagination": { "cursor": "somecursor" } } ``` ``` -------------------------------- ### Initialize Helix Client with App Access Token and Scopes Source: https://github.com/nicklaw5/helix/blob/main/docs/README.md Provide an app access token and specific scopes during client initialization to enable automatic app access token refreshes with those scopes included. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", ClientSecret: "your-client-secret", AppAccessToken: "your-app-access-token", AppAccessScopes: []string{"your-scope"}, }) ``` -------------------------------- ### Get Global Emotes Source: https://github.com/nicklaw5/helix/blob/main/docs/chat_docs.md Retrieves all global emotes available. ```APIDOC ## Get Global Emotes ### Description Retrieves all global emotes available. ### Method GET (Assumed based on function name and typical API patterns) ### Endpoint `/chat/emotes/global` (Assumed based on function name and typical API patterns) ### Parameters None ### Request Example ```json {} ``` ### Response #### Success Response (200) - (Structure not provided in source, but typically contains emote information) #### Response Example ```json { "data": [ { "id": "123", "name": "emote_name", "images": { "1x": "...", "2x": "...", "4x": "..." } } ] } ``` ``` -------------------------------- ### Initialize Helix Client and Create Extension JWT Source: https://github.com/nicklaw5/helix/blob/main/docs/extensions_docs.md Initializes a Helix client with extension options and creates a signed JWT for extension requests. This JWT is then set on the client for subsequent requests. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", UserAccessToken: "your-user-access-token", ExtensionOpts: helix.ExtensionOptions{ OwnerUserID: os.Getenv(""), Secret: os.Getenv(""), ConfigurationVersion: os.Getenv(""), Version: os.Getenv(""), }, }) // see docs below to see what pub-sub permissions you can pass claims, err := client.ExtensionCreateClaims(broadcasterID, client.FormBroadcastSendPubSubPermissions(), 0) if err != nil { // handle err } jwt,err := client.ExtensionJWTSign(claims) if err != nil { // handle err } // set this before doing extension endpoint requests client.SetExtensionSignedJWTToken(jwt) ``` -------------------------------- ### Initialize Client with Default Rate Limiter Source: https://github.com/nicklaw5/helix/blob/main/docs/README.md Initializes the Helix client using the default rate limit function, which automatically waits for the rate limit reset time before retrying. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", RateLimitFunc: helix.DefaultRateLimitFunc, }) if err != nil { // handle error } ``` -------------------------------- ### Get Emote Sets Source: https://github.com/nicklaw5/helix/blob/main/docs/chat_docs.md Retrieves a set of emotes based on provided EmoteSetIDs. ```APIDOC ## Get Emote Sets ### Description Retrieves a set of emotes based on provided EmoteSetIDs. ### Method GET (Assumed based on function name and typical API patterns) ### Endpoint `/chat/emotes/set` (Assumed based on function name and typical API patterns) ### Parameters #### Query Parameters - **emote_set_ids** (array of strings) - Required - The IDs of the emote sets to retrieve. ### Request Example ```json { "emote_set_ids": ["300678379"] } ``` ### Response #### Success Response (200) - (Structure not provided in source, but typically contains emote set information) #### Response Example ```json { "data": [ { "id": "300678379", "emotes": [ { "id": "123", "name": "emote_name", "images": { "1x": "...", "2x": "...", "4x": "..." } } ] } ] } ``` ``` -------------------------------- ### Get Channel Emotes Source: https://github.com/nicklaw5/helix/blob/main/docs/chat_docs.md Retrieves emotes for a specific channel. Requires BroadcasterID. ```APIDOC ## Get Channel Emotes ### Description Retrieves emotes for a specific channel. ### Method GET (Assumed based on function name and typical API patterns) ### Endpoint `/chat/emotes` (Assumed based on function name and typical API patterns) ### Parameters #### Query Parameters - **broadcaster_id** (string) - Required - The ID of the broadcaster whose emotes are being requested. ### Request Example ```json { "broadcaster_id": "145328278" } ``` ### Response #### Success Response (200) - (Structure not provided in source, but typically contains emote information) #### Response Example ```json { "data": [ { "id": "123", "name": "emote_name", "images": { "1x": "...", "2x": "...", "4x": "..." } } ] } ``` ``` -------------------------------- ### Get Global Chat Badges Source: https://github.com/nicklaw5/helix/blob/main/docs/chat_docs.md Retrieves all global chat badges available. ```APIDOC ## Get Global Chat Badges ### Description Retrieves all global chat badges available. ### Method GET (Assumed based on function name and typical API patterns) ### Endpoint `/chat/badges/global` (Assumed based on function name and typical API patterns) ### Parameters None ### Request Example ```json {} ``` ### Response #### Success Response (200) - (Structure not provided in source, but typically contains badge information) #### Response Example ```json { "data": [ { "set_id": "123", "versions": [ { "id": "1", "image_url_1x": "...", "image_url_2x": "...", "image_url_4x": "..." } ] } ] } ``` ``` -------------------------------- ### Initialize Helix Client with Context Source: https://github.com/nicklaw5/helix/blob/main/docs/README.md Create a new Helix API client, passing a context for managing request lifecycles. This is useful for cancellation and timeouts. ```go client, err := helix.NewClientWithContext(ctx, &helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } ``` -------------------------------- ### Initialize Helix Client with Custom HTTP Client Source: https://github.com/nicklaw5/helix/blob/main/docs/README.md Create a new Helix API client using a pre-configured http.Client. This allows for custom transport settings, timeouts, and connection pooling. ```go httpClient := &http.Client{ Transport: &http.Transport{ MaxIdleConns: 10, IdleConnTimeout: 30 * time.Second, }, Timeout: 10 * time.Second, } client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", HTTPClient: httpClient, }) if err != nil { // handle error } ``` -------------------------------- ### Get Channel Chat Badges Source: https://github.com/nicklaw5/helix/blob/main/docs/chat_docs.md Retrieves chat badges for a specific channel. Requires BroadcasterID. ```APIDOC ## Get Channel Chat Badges ### Description Retrieves chat badges for a specific channel. ### Method GET (Assumed based on function name and typical API patterns) ### Endpoint `/chat/badges` (Assumed based on function name and typical API patterns) ### Parameters #### Query Parameters - **broadcaster_id** (string) - Required - The ID of the broadcaster whose chat badges are being requested. ### Request Example ```json { "broadcaster_id": "145328278" } ``` ### Response #### Success Response (200) - (Structure not provided in source, but typically contains badge information) #### Response Example ```json { "data": [ { "set_id": "123", "versions": [ { "id": "1", "image_url_1x": "...", "image_url_2x": "...", "image_url_4x": "..." } ] } ] } ``` ``` -------------------------------- ### Get Channel Emotes Source: https://github.com/nicklaw5/helix/blob/main/docs/chat_docs.md Retrieve chat emotes for a specific broadcaster. Requires a client with a ClientID. ```go client, err := helix.NewClient(&helix.Options{ ClientID: "your-client-id", }) if err != nil { // handle error } resp, err := client.GetChannelEmotes(&helix.GetChannelEmotesParams{ BroadcasterID: "145328278", }) if err != nil { // handle error } fmt.Printf("%+v\n", resp) ```