8000 helix/docs at master · jakefolio/helix · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
< 8000 script type="application/json" data-target="react-app.embeddedData">{"payload":{"allShortcutsEnabled":false,"path":"docs","repo":{"id":263937947,"defaultBranch":"master","name":"helix","ownerLogin":"jakefolio","currentUserCanPush":false,"isFork":true,"isEmpty":false,"createdAt":"2020-05-14T14:28:31.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/199860?v=4","public":true,"private":false,"isOrgOwned":false},"currentUser":null,"refInfo":{"name":"master","listCacheKey":"v0:1589490841.0","canEdit":false,"refType":"branch","currentOid":"fec91a20a3a1f95afc38f88ba83e097bf29b0e92"},"tree":{"items":[{"name":"README.md","path":"docs/README.md","contentType":"file"},{"name":"analytics_docs.md","path":"docs/analytics_docs.md","contentType":"file"},{"name":"authentication_docs.md","path":"docs/authentication_docs.md","contentType":"file"},{"name":"bits_docs.md","path":"docs/bits_docs.md","contentType":"file"},{"name":"clips_docs.md","path":"docs/clips_docs.md","contentType":"file"},{"name":"entitlement_grants_docs.md","path":"docs/entitlement_grants_docs.md","contentType":"file"},{"name":"games_docs.md","path":"docs/games_docs.md","contentType":"file"},{"name":"moderation_docs.md","path":"docs/moderation_docs.md","contentType":"file"},{"name":"stream_markers_docs.md","path":"docs/stream_markers_docs.md","contentType":"file"},{"name":"streams_docs.md","path":"docs/streams_docs.md","contentType":"file"},{"name":"subscriptions_docs.md","path":"docs/subscriptions_docs.md","contentType":"file"},{"name":"user_extensions.md","path":"docs/user_extensions.md","contentType":"file"},{"name":"users_docs.md","path":"docs/users_docs.md","contentType":"file"},{"name":"videos_docs.md","path":"docs/videos_docs.md","contentType":"file"},{"name":"webhook_docs.md","path":"docs/webhook_docs.md","contentType":"file"}],"templateDirectorySuggestionUrl":null,"readme":{"displayName":"README.md","richText":"\u003carticle class=\"markdown-body entry-content container-lg\" itemprop=\"text\"\u003e\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch1 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eDocumentation\u003c/h1\u003e\u003ca id=\"user-content-documentation\" class=\"anchor\" aria-label=\"Permalink: Documentation\" href=\"#documentation\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eUsage Examples\u003c/h2\u003e\u003ca id=\"user-content-usage-examples\" class=\"anchor\" aria-label=\"Permalink: Usage Examples\" href=\"#usage-examples\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eFollow the links below to their respective API usage examples:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ca href=\"/jakefolio/helix/blob/master/docs/analytics_docs.md\"\u003eAnalytics\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"/jakefolio/helix/blob/master/docs/authentication_docs.md\"\u003eAuthentication\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"/jakefolio/helix/blob/master/docs/bits_docs.md\"\u003eBits\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"/jakefolio/helix/blob/master/docs/clips_docs.md\"\u003eClips\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"/jakefolio/helix/blob/master/docs/entitlement_grants_docs.md\"\u003eEntitlement Grants\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"/jakefolio/helix/blob/master/docs/games_docs.md\"\u003eGames\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"/jakefolio/helix/blob/master/docs/streams_docs.md\"\u003eStreams\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"/jakefolio/helix/blob/master/docs/users_docs.md\"\u003eUsers\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"/jakefolio/helix/blob/master/docs/videos_docs.md\"\u003eVideos\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"/jakefolio/helix/blob/master/docs/webhook_docs.md\"\u003eWebhook Subscriptions\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eGetting Started\u003c/h2\u003e\u003ca id=\"user-content-getting-started\" class=\"anchor\" aria-label=\"Permalink: Getting Started\" href=\"#getting-started\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eIt's recommended that you use a dependency management tool such as \u003ca href=\"https://github.com/golang/dep\"\u003eDep\u003c/a\u003e. If you are using Dep you can import helix by running:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"dep ensure -add github.com/nicklaw5/helix\"\u003e\u003cpre\u003edep ensure -add github.com/nicklaw5/helix\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eOr you can simply import using the Go toolchain:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"go get -u github.com/nicklaw5/helix\"\u003e\u003cpre\u003ego get -u github.com/nicklaw5/helix\u003c/pre\u003e\u003c/div\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eCreating A New API Client\u003c/h2\u003e\u003ca id=\"user-content-creating-a-new-api-client\" class=\"anchor\" aria-label=\"Permalink: Creating A New API Client\" href=\"#creating-a-new-api-client\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThe only requirement for creating a new API client is your Twitch Client-ID. See the \u003ca href=\"https://dev.twitch.tv/docs/authentication\" rel=\"nofollow\"\u003eTwitch authentication docs\u003c/a\u003e on how to obtain a Client-ID. Once you have a Client-ID, to create a new client simply the \u003ccode\u003eNewClient\u003c/code\u003e function. passing through your client ID as an option. For example:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-go notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"client, err := helix.NewClient(\u0026amp;helix.Options{\n ClientID: \u0026quot;your-client-id\u0026quot;,\n})\nif err != nil {\n // handle error\n}\"\u003e\u003cpre\u003e\u003cspan class=\"pl-s1\"\u003eclient\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003eerr\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e:=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ehelix\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eNewClient\u003c/span\u003e(\u003cspan class=\"pl-c1\"\u003e\u0026amp;\u003c/span\u003ehelix.\u003cspan class=\"pl-smi\"\u003eOptions\u003c/span\u003e{\n \u003cspan class=\"pl-s1\"\u003eClientID\u003c/span\u003e: \u003cspan class=\"pl-s\"\u003e\"your-client-id\"\u003c/span\u003e,\n})\n\u003cspan class=\"pl-k\"\u003eif\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eerr\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e!=\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003enil\u003c/span\u003e {\n \u003cspan class=\"pl-c\"\u003e// handle error\u003c/span\u003e\n}\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eIf you'd like to pass in your own \u003ccode\u003ehttp.Client\u003c/code\u003e, you can do so like this:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-go notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"httpClient := \u0026amp;http.Client{\n Transport: \u0026amp;http.Transport{\n MaxIdleConns: 10,\n IdleConnTimeout: 30 * time.Second,\n },\n Timeout: 10 * time.Second,\n}\n\nclient, err := helix.NewClient(\u0026amp;helix.Options{\n ClientID: \u0026quot;your-client-id\u0026quot;,\n HTTPClient: httpClient,\n})\nif err != nil {\n // handle error\n}\"\u003e\u003cpre\u003e\u003cspan class=\"pl-s1\"\u003ehttpClient\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e:=\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026amp;\u003c/span\u003ehttp.\u003cspan class=\"pl-smi\"\u003eClient\u003c/span\u003e{\n \u003cspan class=\"pl-s1\"\u003eTransport\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e\u0026amp;\u003c/span\u003ehttp.\u003cspan class=\"pl-smi\"\u003eTransport\u003c/span\u003e{\n \u003cspan class=\"pl-s1\"\u003eMaxIdleConns\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e10\u003c/span\u003e,\n \u003cspan class=\"pl-s1\"\u003eIdleConnTimeout\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e30\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e*\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003etime\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eSecond\u003c/span\u003e,\n },\n \u003cspan class=\"pl-s1\"\u003eTimeout\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e10\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e*\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003etime\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eSecond\u003c/span\u003e,\n}\n\n\u003cspan class=\"pl-s1\"\u003eclient\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003eerr\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e:=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ehelix\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eNewClient\u003c/span\u003e(\u003cspan class=\"pl-c1\"\u003e\u0026amp;\u003c/span\u003ehelix.\u003cspan class=\"pl-smi\"\u003eOptions\u003c/span\u003e{\n \u003cspan class=\"pl-s1\"\u003eClientID\u003c/span\u003e: \u003cspan class=\"pl-s\"\u003e\"your-client-id\"\u003c/span\u003e,\n \u003cspan class=\"pl-s1\"\u003eHTTPClient\u003c/span\u003e: \u003cspan class=\"pl-s1\"\u003ehttpClient\u003c/span\u003e,\n})\n\u003cspan class=\"pl-k\"\u003eif\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eerr\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e!=\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003enil\u003c/span\u003e {\n \u003cspan class=\"pl-c\"\u003e// handle error\u003c/span\u003e\n}\u003c/pre\u003e\u003c/div\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eOptions\u003c/h2\u003e\u003ca id=\"user-content-options\" class=\"anchor\" aria-label=\"Permalink: Options\" href=\"#options\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eBelow is a list of all available options that can be passed in when creating a new client:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-go notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"type Options struct {\n ClientID string // Required\n ClientSecret string // Default: empty string\n AppAccessToken string // Default: empty string\n UserAccessToken string // Default: empty string\n UserAgent string // Default: empty string\n RedirectURI string // Default: empty string\n Scopes []string // Default: empty string slice\n HTTPClient HTTPClient // Default: http.DefaultClient\n RateLimitFunc RateLimitFunc // Default: nil\n}\"\u003e\u003cpre\u003e\u003cspan class=\"pl-k\"\u003etype\u003c/span\u003e \u003cspan class=\"pl-smi\"\u003eOptions\u003c/span\u003e \u003cspan class=\"pl-k\"\u003estruct\u003c/span\u003e {\n \u003cspan class=\"pl-c1\"\u003eClientID\u003c/span\u003e \u003cspan class=\"pl-smi\"\u003estring\u003c/span\u003e \u003cspan class=\"pl-c\"\u003e// Required\u003c/span\u003e\n \u003cspan class=\"pl-c1\"\u003eClientSecret\u003c/span\u003e \u003cspan class=\"pl-smi\"\u003estring\u003c/span\u003e \u003cspan class=\"pl-c\"\u003e// Default: empty string\u003c/span\u003e\n \u003cspan class=\"pl-c1\"\u003eAppAccessToken\u003c/span\u003e \u003cspan class=\"pl-smi\"\u003estring\u003c/span\u003e \u003cspan class=\"pl-c\"\u003e// Default: empty string\u003c/span\u003e\n \u003cspan class=\"pl-c1\"\u003eUserAccessToken\u003c/span\u003e \u003cspan class=\"pl-smi\"\u003estring\u003c/span\u003e \u003cspan class=\"pl-c\"\u003e// Default: empty string\u003c/span\u003e\n \u003cspan class=\"pl-c1\"\u003eUserAgent\u003c/span\u003e \u003cspan class=\"pl-smi\"\u003estring\u003c/span\u003e \u003cspan class=\"pl-c\"\u003e// Default: empty string\u003c/span\u003e\n \u003cspan class=\"pl-c1\"\u003eRedirectURI\u003c/span\u003e \u003cspan class=\"pl-smi\"\u003estring\u003c/span\u003e \u003cspan class=\"pl-c\"\u003e// Default: empty string\u003c/span\u003e\n \u003cspan class=\"pl-c1\"\u003eScopes\u003c/span\u003e []\u003cspan class=\"pl-smi\"\u003estring\u003c/span\u003e \u003cspan class=\"pl-c\"\u003e// Default: empty string slice\u003c/span\u003e\n \u003cspan class=\"pl-c1\"\u003eHTTPClient\u003c/span\u003e \u003cspan class=\"pl-smi\"\u003eHTTPClient\u003c/span\u003e \u003cspan class=\"pl-c\"\u003e// Default: http.DefaultClient\u003c/span\u003e\n \u003cspan class=\"pl-c1\"\u003eRateLimitFunc\u003c/span\u003e \u003cspan class=\"pl-smi\"\u003eRateLimitFunc\u003c/span\u003e \u003cspan class=\"pl-c\"\u003e// Default: nil\u003c/span\u003e\n}\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eIf no custom \u003ccode\u003ehttp.Client\u003c/code\u003e is provided, \u003ccode\u003ehttp.DefaultClient\u003c/code\u003e is used by default.\u003c/p\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eResponses\u003c/h2\u003e\u003ca id=\"user-content-responses\" class=\"anchor\" aria-label=\"Permalink: Responses\" href=\"#responses\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eIt is common for a Twitch API request to simply fail sometimes. Occasionally a request gets hung up and eventually fails with a 500 internal server error. It's also possible that an invalid request was sent and Twitch responded with an error. To assist in circumstances such as these, the HTTP status code is returned with each API request, along with any error that may been encountered. For example, notice below that the \u003ccode\u003eUsersResponse\u003c/code\u003e struct, which is returned with the \u003ccode\u003eGetUsers()\u003c/code\u003e method, includes fields from the \u003ccode\u003eResponseCommon\u003c/code\u003e struct.\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-go notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"type UsersResponse struct {\n ResponseCommon\n Data ManyUsers\n}\n\ntype ManyUsers struct {\n Users []User `json:\u0026quot;data\u0026quot;`\n}\n\ntype ResponseCommon struct {\n StatusCode int\n Header http.Header\n Error string `json:\u0026quot;error\u0026quot;`\n ErrorStatus int `json:\u0026quot;status\u0026quot;`\n ErrorMessage string `json:\u0026quot;message\u0026quot;`\n}\"\u003e\u003cpre\u003e\u003cspan class=\"pl-k\"\u003etype\u003c/span\u003e \u003cspan class=\"pl-smi\"\u003eUsersResponse\u003c/span\u003e \u003cspan class=\"pl-k\"\u003estruct\u003c/span\u003e {\n \u003cspan class=\"pl-smi\"\u003eResponseCommon\u003c/span\u003e\n \u003cspan class=\"pl-c1\"\u003eData\u003c/span\u003e \u003cspan class=\"pl-smi\"\u003eManyUsers\u003c/span\u003e\n}\n\n\u003cspan class=\"pl-k\"\u003etype\u003c/span\u003e \u003cspan class=\"pl-smi\"\u003eManyUsers\u003c/span\u003e \u003cspan class=\"pl-k\"\u003estruct\u003c/span\u003e {\n \u003cspan class=\"pl-c1\"\u003eUsers\u003c/span\u003e []\u003cspan class=\"pl-smi\"\u003eUser\u003c/span\u003e \u003cspan class=\"pl-s\"\u003e`json:\"data\"`\u003c/span\u003e\n}\n\n\u003cspan class=\"pl-k\"\u003etype\u003c/span\u003e \u003cspan class=\"pl-smi\"\u003eResponseCommon\u003c/span\u003e \u003cspan class=\"pl-k\"\u003estruct\u003c/span\u003e {\n \u003cspan class=\"pl-c1\"\u003eStatusCode\u003c/span\u003e \u003cspan class=\"pl-smi\"\u003eint\u003c/span\u003e\n \u003cspan class=\"pl-c1\"\u003eHeader\u003c/span\u003e http.\u003cspan class=\"pl-smi\"\u003eHeader\u003c/span\u003e\n \u003cspan class=\"pl-c1\"\u003eError\u003c/span\u003e \u003cspan class=\"pl-smi\"\u003estring\u003c/span\u003e \u003cspan class=\"pl-s\"\u003e`json:\"error\"`\u003c/span\u003e\n \u003cspan class=\"pl-c1\"\u003eErrorStatus\u003c/span\u003e \u003cspan class=\"pl-smi\"\u003eint\u003c/span\u003e \u003cspan class=\"pl-s\"\u003e`json:\"status\"`\u003c/span\u003e\n \u003cspan class=\"pl-c1\"\u003eErrorMessage\u003c/span\u003e \u003cspan class=\"pl-smi\"\u003estring\u003c/span\u003e \u003cspan class=\"pl-s\"\u003e`json:\"message\"`\u003c/span\u003e\n}\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eAlso note from above that the \u003ccode\u003eResponseCommon\u003c/code\u003e struct includes the header results returned with each request.\u003c/p\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eRequest Rate Limiting\u003c/h2\u003e\u003ca id=\"user-content-request-rate-limiting\" class=\"anchor\" aria-label=\"Permalink: Request Rate Limiting\" href=\"#request-rate-limiting\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eTwitch enforces strict request rate limits for their API. See \u003ca href=\"https://dev.twitch.tv/docs/api#rate-limits\" rel=\"nofollow\"\u003etheir documentation\u003c/a\u003e for the specific rate limit values. At the time of writing this, requests are limited to 30 queries per minute (if a Bearer token is not provided) or 120 queries per minute (if a Bearer token is provided).\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThere are a number of helper methods on the response object for retrieving rate limit headers are integers. These include:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ccode\u003eResponse.GetRateLimit()\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003eResponse.GetRateLimitRemaining()\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003eResponse.GetRateLimitReset()\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003eResponse.GetClipsCreationRateLimit()\u003c/code\u003e (only available when called \u003ccode\u003eclient.CreateClip()\u003c/code\u003e)\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003eResponse.GetClipsCreationRateLimitRemaining()\u003c/code\u003e (only available when called \u003ccode\u003eclient.CreateClip()\u003c/code\u003e)\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003eResponse.GetStreamsMetadataRateLimit()\u003c/code\u003e (only available when called \u003ccode\u003eclient.GetStreamsMetadata()\u003c/code\u003e)\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003eResponse.GetStreamsMetadataRateLimitRemaining()\u003c/code\u003e (only available when called \u003ccode\u003eclient.GetStreamsMetadata()\u003c/code\u003e)\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eThis package also allows users to provide a rate limit callback of their own which will be executed just before a request is sent. That way you can provide some sort of functionality for limiting the requests sent and prevent spamming Twitch with requests.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe below snippet provides an example of how you might structure your rate limit callback to approach limiting requests. In this example, once we've reached our rate limit, we'll simply wait for the limit to pass before sending the next request.\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-go notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"func rateLimitCallback(lastResponse *helix.Response) error {\n if lastResponse.GetRateLimitRemaining() \u0026gt; 0 {\n return nil\n }\n\n var reset64 int64\n reset64 = int64(lastResponse.GetRateLimitReset())\n\n currentTime := time.Now().Unix()\n\n if currentTime \u0026lt; reset64 {\n timeDiff := time.Duration(reset64 - currentTime)\n if timeDiff \u0026gt; 0 {\n fmt.Printf(\u0026quot;Waiting on rate limit to pass before sending next request (%d seconds)\\n\u0026quot;, timeDiff)\n time.Sleep(timeDiff * time.Second)\n }\n }\n\n return nil\n}\n\nclient, err := helix.NewClient(\u0026amp;helix.Options{\n ClientID: \u0026quot;your-client-id\u0026quot;,\n RateLimitFunc: rateLimitCallback,\n})\nif err != nil {\n // handle error\n}\"\u003e\u003cpre\u003e\u003cspan class=\"pl-k\"\u003efunc\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003erateLimitCallback\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003elastResponse\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e*\u003c/span\u003ehelix.\u003cspan class=\"pl-smi\"\u003eResponse\u003c/span\u003e) \u003cspan class=\"pl-smi\"\u003eerror\u003c/span\u003e {\n \u003cspan class=\"pl-k\"\u003eif\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003elastResponse\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eGetRateLimitRemaining\u003c/span\u003e() \u003cspan class=\"pl-c1\"\u003e\u0026gt;\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e0\u003c/span\u003e {\n \u003cspan class=\"pl-k\"\u003ereturn\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003enil\u003c/span\u003e\n }\n\n \u003cspan class=\"pl-k\"\u003evar\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ereset64\u003c/span\u003e \u003cspan class=\"pl-smi\"\u003eint64\u003c/span\u003e\n \u003cspan class=\"pl-s1\"\u003ereset64\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eint64\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003elastResponse\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eGetRateLimitReset\u003c/span\u003e())\n\n \u003cspan class=\"pl-s1\"\u003ecurrentTime\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e:=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003etime\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eNow\u003c/span\u003e().\u003cspan class=\"pl-c1\"\u003eUnix\u003c/span\u003e()\n\n \u003cspan class=\"pl-k\"\u003eif\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ecurrentTime\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026lt;\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ereset64\u003c/span\u003e {\n \u003cspan class=\"pl-s1\"\u003etimeDiff\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e:=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003etime\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eDuration\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003ereset64\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ecurrentTime\u003c/span\u003e)\n \u003cspan class=\"pl-k\"\u003eif\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003etimeDiff\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026gt;\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e0\u003c/span\u003e {\n \u003cspan class=\"pl-s1\"\u003efmt\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003ePrintf\u003c/span\u003e(\u003cspan class=\"pl-s\"\u003e\"Waiting on rate limit to pass before sending next request (%d seconds)\u003cspan class=\"pl-cce\"\u003e\\n\u003c/span\u003e\"\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003etimeDiff\u003c/span\u003e)\n \u003cspan class=\"pl-s1\"\u003etime\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eSleep\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003etimeDiff\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e*\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003etime\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eSecond\u003c/span\u003e)\n }\n }\n\n \u003cspan class=\"pl-k\"\u003ereturn\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003enil\u003c/span\u003e\n}\n\n\u003cspan class=\"pl-s1\"\u003eclient\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003eerr\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e:=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ehelix\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eNewClient\u003c/span\u003e(\u003cspan class=\"pl-c1\"\u003e\u0026amp;\u003c/span\u003ehelix.\u003cspan class=\"pl-smi\"\u003eOptions\u003c/span\u003e{\n \u003cspan class=\"pl-s1\"\u003eClientID\u003c/span\u003e: \u003cspan class=\"pl-s\"\u003e\"your-client-id\"\u003c/span\u003e,\n \u003cspan class=\"pl-s1\"\u003eRateLimitFunc\u003c/span\u003e: \u003cspan class=\"pl-s1\"\u003erateLimitCallback\u003c/span\u003e,\n})\n\u003cspan class=\"pl-k\"\u003eif\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eerr\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e!=\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003enil\u003c/span\u003e {\n \u003cspan class=\"pl-c\"\u003e// handle error\u003c/span\u003e\n}\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eIf a \u003ccode\u003eRateLimitFunc\u003c/code\u003e is provided, the client will re-attempt to send a failed request if said request received a 429 (Too Many Requests) response. Before retrying the request, the \u003ccode\u003eRateLimitFunc\u003c/code\u003e will be applied.\u003c/p\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eAccess Tokens\u003c/h2\u003e\u003ca id=\"user-content-access-tokens\" class=\"anchor\" aria-label=\"Permalink: Access Tokens\" href=\"#access-tokens\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eSome API endpoints require that you have a valid access token in order to fulfill the request. There are two types of access tokens: app access tokens and user access tokens.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eApp access tokens allow game developers to integrate their game into Twitch's viewing experience. \u003ca href=\"https://dev.twitch.tv/drops\" rel=\"nofollow\"\u003eDrops\u003c/a\u003e are an example of this.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eUser access tokens, on the other hand, are used to interact with the Twitch API on behalf of a registered Twitch user. If you're only looking to consume the standard API, such as getting access to a user's registered email address, user access tokens are what you will need.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eIt is worth noting that both app and user access tokens have the ability to extend the request rate limit enforced by Twitch. However, if you provide both an app and a user token - as is the case in the below example - the app access token will be ignored as user access tokens are prioritized when setting the request \u003cem\u003eAuthorization\u003c/em\u003e header.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eIn order to set the access token for a request, you can either supply it as an option or use the \u003ccode\u003eSetUserAccessToken\u003c/code\u003e or \u003ccode\u003eSetAppAccessToken\u003c/code\u003e methods. For example:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-go notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"cli 5C89 ent, err := helix.NewClient(\u0026amp;helix.Options{\n ClientID: \u0026quot;your-client-id\u0026quot;,\n UserAccessToken: \u0026quot;your-user-access-token\u0026quot;,\n AppAccessToken: \u0026quot;your-app-access-token\u0026quot;\n})\nif err != nil {\n // handle error\n}\n\n// send API request...\"\u003e\u003cpre\u003e\u003cspan class=\"pl-s1\"\u003eclient\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003eerr\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e:=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ehelix\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eNewClient\u003c/span\u003e(\u003cspan class=\"pl-c1\"\u003e\u0026amp;\u003c/span\u003ehelix.\u003cspan class=\"pl-smi\"\u003eOptions\u003c/span\u003e{\n \u003cspan class=\"pl-s1\"\u003eClientID\u003c/span\u003e: \u003cspan class=\"pl-s\"\u003e\"your-client-id\"\u003c/span\u003e,\n \u003cspan class=\"pl-s1\"\u003eUserAccessToken\u003c/span\u003e: \u003cspan class=\"pl-s\"\u003e\"your-user-access-token\"\u003c/span\u003e,\n \u003cspan class=\"pl-s1\"\u003eAppAccessToken\u003c/span\u003e: \u003cspan class=\"pl-s\"\u003e\"your-app-access-token\"\u003c/span\u003e\n})\n\u003cspan class=\"pl-k\"\u003eif\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eerr\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e!=\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003enil\u003c/span\u003e {\n \u003cspan class=\"pl-c\"\u003e// handle error\u003c/span\u003e\n}\n\n\u003cspan class=\"pl-c\"\u003e// send API request...\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eOr:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-go notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"client, err := helix.NewClient(\u0026amp;helix.Options{\n ClientID: \u0026quot;your-client-id\u0026quot;,\n})\nif err != nil {\n // handle error\n}\n\nclient.SetUserAccessToken(\u0026quot;your-user-access-token\u0026quot;)\nclient.SetAppAccessToken(\u0026quot;your-app-access-token\u0026quot;)\n\n// send API request...\"\u003e\u003cpre\u003e\u003cspan class=\"pl-s1\"\u003eclient\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003eerr\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e:=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ehelix\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eNewClient\u003c/span\u003e(\u003cspan class=\"pl-c1\"\u003e\u0026amp;\u003c/span\u003ehelix.\u003cspan class=\"pl-smi\"\u003eOptions\u003c/span\u003e{\n \u003cspan class=\"pl-s1\"\u003eClientID\u003c/span\u003e: \u003cspan class=\"pl-s\"\u003e\"your-client-id\"\u003c/span\u003e,\n})\n\u003cspan class=\"pl-k\"\u003eif\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eerr\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e!=\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003enil\u003c/span\u003e {\n \u003cspan class=\"pl-c\"\u003e// handle error\u003c/span\u003e\n}\n\n\u003cspan class=\"pl-s1\"\u003eclient\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eSetUserAccessToken\u003c/span\u003e(\u003cspan class=\"pl-s\"\u003e\"your-user-access-token\"\u003c/span\u003e)\n\u003cspan class=\"pl-s1\"\u003eclient\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eSetAppAccessToken\u003c/span\u003e(\u003cspan class=\"pl-s\"\u003e\"your-app-access-token\"\u003c/span\u003e)\n\n\u003cspan class=\"pl-c\"\u003e// send API request...\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eNote that any subsequent API requests will utilize this same access token. So it is necessary to unset the access token when you are finished with it. To do so, simply pass an empty string to the \u003ccode\u003eSetUserAccessToken\u003c/code\u003e or \u003ccode\u003eSetAppAccessToken\u003c/code\u003e methods.\u003c/p\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eUser-Agent Header\u003c/h2\u003e\u003ca id=\"user-content-user-agent-header\" class=\"anchor\" aria-label=\"Permalink: User-Agent Header\" href=\"#user-agent-header\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eIt's entirely possible that you may want to set or change the \u003cem\u003eUser-Agent\u003c/em\u003e header value that is sent with each request. You can do so by passing it through as an option when creating a new client, like so:\u003c/p\u003e\n\u003cp dir=\"auto\"\u003ewith the \u003ccode\u003eSetUserAgent()\u003c/code\u003e method before sending a request. For example:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-go notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"client, err := helix.NewClient(\u0026amp;helix.Options{\n ClientID: \u0026quot;your-client-id\u0026quot;,\n UserAgent: \u0026quot;your-user-agent-value\u0026quot;,\n})\nif err != nil {\n // handle error\n}\n\n\n// send API request...\"\u003e\u003cpre\u003e\u003cspan class=\"pl-s1\"\u003eclient\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003eerr\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e:=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ehelix\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eNewClient\u003c/span\u003e(\u003cspan class=\"pl-c1\"\u003e\u0026amp;\u003c/span\u003ehelix.\u003cspan class=\"pl-smi\"\u003eOptions\u003c/span\u003e{\n \u003cspan class=\"pl-s1\"\u003eClientID\u003c/span\u003e: \u003cspan class=\"pl-s\"\u003e\"your-client-id\"\u003c/span\u003e,\n \u003cspan class=\"pl-s1\"\u003eUserAgent\u003c/span\u003e: \u003cspan class=\"pl-s\"\u003e\"your-user-agent-value\"\u003c/span\u003e,\n})\n\u003cspan class=\"pl-k\"\u003eif\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eerr\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e!=\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003enil\u003c/span\u003e {\n \u003cspan class=\"pl-c\"\u003e// handle error\u003c/span\u003e\n}\n\n\n\u003cspan class=\"pl-c\"\u003e// send API request...\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eAlternatively, you can set by calling the \u003ccode\u003eSetUserAgent()\u003c/code\u003e method before sending a request. For example:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-go notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"client, err := helix.NewClient(\u0026amp;helix.Options{\n ClientID: \u0026quot;your-client-id\u0026quot;,\n})\nif err != nil {\n // handle error\n}\n\nclient.SetUserAgent(\u0026quot;your-user-agent-value\u0026quot;)\n\n// send API request...\"\u003e\u003cpre\u003e\u003cspan class=\"pl-s1\"\u003eclient\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003eerr\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e:=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ehelix\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eNewClient\u003c/span\u003e(\u003cspan class=\"pl-c1\"\u003e\u0026amp;\u003c/span\u003ehelix.\u003cspan class=\"pl-smi\"\u003eOptions\u003c/span\u003e{\n \u003cspan class=\"pl-s1\"\u003eClientID\u003c/span\u003e: \u003cspan class=\"pl-s\"\u003e\"your-client-id\"\u003c/span\u003e,\n})\n\u003cspan class=\"pl-k\"\u003eif\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eerr\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e!=\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003enil\u003c/span\u003e {\n \u003cspan class=\"pl-c\"\u003e// handle error\u003c/span\u003e\n}\n\n\u003cspan class=\"pl-s1\"\u003eclient\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eSetUserAgent\u003c/span\u003e(\u003cspan class=\"pl-s\"\u003e\"your-user-agent-value\"\u003c/span\u003e)\n\n\u003cspan class=\"pl-c\"\u003e// send API request...\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003c/article\u003e","errorMessage":null,"headerInfo":{"toc":[{"level":1,"text":"Documentation","anchor":"documentation","htmlText":"Documentation"},{"level":2,"text":"Usage Examples","anchor":"usage-examples","htmlText":"Usage Examples"},{"level":2,"text":"Getting Started","anchor":"getting-started","htmlText":"Getting Started"},{"level":2,"text":"Creating A New API Client","anchor":"creating-a-new-api-client","htmlText":"Creating A New API Client"},{"level":2,"text":"Options","anchor":"options","htmlText":"Options"},{"level":2,"text":"Responses","anchor":"responses","htmlText":"Responses"},{"level":2,"text":"Request Rate Limiting","anchor":"request-rate-limiting","htmlText":"Request Rate Limiting"},{"level":2,"text":"Access Tokens","anchor":"access-tokens","htmlText":"Access Tokens"},{"level":2,"text":"User-Agent Header","anchor":"user-agent-header","htmlText":"User-Agent Header"}],"siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fjakefolio%2Fhelix%2Ftree%2Fmaster%2Fdocs"}},"totalCount":15,"showBranchInfobar":true},"fileTree":{"":{"items":[{"name":"docs","path":"docs","contentType":"directory"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".travis.yml","path":".travis.yml","contentType":"file"},{"name":"LICENSE","path":"LICENSE","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"analytics.go","path":"analytics.go","contentType":"file"},{"name":"analytics_test.go","path":"analytics_test.go","contentType":"file"},{"name":"authentication.go","path":"authentication.go","contentType":"file"},{"name":"authentication_test.go","path":"authentication_test.go","contentType":"file"},{"name":"bits.go","path":"bits.go","contentType":"file"},{"name":"bits_test.go","path":"bits_test.go","contentType":"file"},{"name":"clips.go","path":"clips.go","contentType":"file"},{"name":"clips_test.go","path":"clips_test.go","contentType":"file"},{"name":"entitlement_grants.go","path":"entitlement_grants.go","contentType":"file"},{"name":"entitlement_grants_test.go","path":"entitlement_grants_test.go","contentType":"file"},{"name":"games.go","path":"games.go","contentType":"file"},{"name":"games_test.go","path":"games_test.go","contentType":"file"},{"name":"helix.go","path":"helix.go","contentType":"file"},{"name":"helix_test.go","path":"helix_test.go","contentType":"file"},{"name":"moderation.go","path":"moderation.go","contentType":"file"},{"name":"moderation_test.go","path":"moderation_test.go","contentType":"file"},{"name":"stream_markers.go","path":"stream_markers.go","contentType":"file"},{"name":"stream_markers_test.go","path":"stream_markers_test.go","contentType":"file"},{"name":"streams.go","path":"streams.go","contentType":"file"},{"name":"streams_test.go","path":"streams_test.go","contentType":"file"},{"name":"subscriptions.go","path":"subscriptions.go","contentType":"file"},{"name":"subscriptions_test.go","path":"subscriptions_test.go","contentType":"file"},{"name":"time.go","path":"time.go","contentType":"file"},{"name":"time_test.go","path":"time_test.go","contentType":"file"},{"name":"user_extension_test.go","path":"user_extension_test.go","contentType":"file"},{"name":"user_extensions.go","path":"user_extensions.go","contentType":"file"},{"name":"users.go","path":"users.go","contentType":"file"},{"name":"users_test.go","path":"users_test.go","contentType":"file"},{"name":"videos.go","path":"videos.go","contentType":"file"},{"name":"videos_test.go","path":"videos_test.go","contentType":"file"},{"name":"webhooks.go","path":"webhooks.go","contentType":"file"},{"name":"webhooks_test.go","path":"webhooks_test.go","contentType":"file"}],"totalCount":37}},"fileTreeProcessingTime":7.722749,"foldersToFetch":[],"treeExpanded":true,"symbolsExpanded":false,"csrf_tokens":{"/jakefolio/helix/branches":{"post":"JdbU1Sb-Oe1Tm73GrET1mqCpB4kbeVMPvrDNIWdElzkUiIbeT-5u6dn27a1Bt1_iFmbIPuuDL5vRkfM9pPSraA"},"/jakefolio/helix/branches/fetch_and_merge/master":{"post":"C7cMUVyt1s90ylj3KGqTlap3dvhP-kCJVaRMLHGOu7Vh3OE9IkSAPJ39w13NIeLPqk_GtIsJa48cndKutCoLYQ"},"/jakefolio/helix/branches/fetch_and_merge/master?discard_changes=true":{"post":"tOWi62lbIbfRIY4YCLA2kDrr0-w5eDeMW5aqvmN1Byrejk-HF7J3RDgWFbLt-0fKOtNjoP2LHIoSrzQ8ptG3_g"}}},"title":"helix/docs at master · jakefolio/helix","appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-263cab1760dd.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-98e6e9db3609.js","githubDevUrl":null,"enabled_features":{"code_nav_ui_events":false,"react_blob_overlay":false,"accessible_code_button":true}}}
0