Documentation ¶
Overview ¶
Package helix exposes a client for interacting with the upcomming version of the Twitch.tv API. Helix is considered the "new" and "current" API, though at this time it is incomlete. Kraken is v5 and complete, but considered deprecated and will be turned of ~Dec. 2018. When possible, you should use helix.
Index ¶
- Constants
- type Client
- func (c *Client) Delete(p string, ro *twitch.RequestOptions) (*http.Response, error)
- func (c *Client) Get(p string, ro *twitch.RequestOptions) (*http.Response, error)
- func (k *Client) GetGames(i *GetGamesInput) (*GetGamesOutput, error)
- func (c *Client) Head(p string, ro *twitch.RequestOptions) (*http.Response, error)
- func (c *Client) Post(p string, ro *twitch.RequestOptions) (*http.Response, error)
- func (c *Client) PostForm(p string, i interface{}, ro *twitch.RequestOptions) (*http.Response, error)
- func (c *Client) Put(p string, ro *twitch.RequestOptions) (*http.Response, error)
- func (c *Client) PutForm(p string, i interface{}, ro *twitch.RequestOptions) (*http.Response, error)
- func (c *Client) RawRequest(verb, p string, ro *twitch.RequestOptions) (*http.Request, error)
- func (c *Client) Request(verb, p string, ro *twitch.RequestOptions) (*http.Response, error)
- func (c *Client) RequestForm(verb, p string, i interface{}, ro *twitch.RequestOptions) (*http.Response, error)
- type Game
- type GetGamesInput
- type GetGamesOutput
Constants ¶
const AccessTokenEnvVar = "TWITCH_ACCESS_TOKEN"
AccessTokenEnvVar is the name of the environment variable where the Twitch API key should be read from. ClientIdEnvVar is the name of the environment variable the client id should be read from.
const AccessTokenHeader = "Authorization"
AccessTokenHeader is the name of the header that contains the Twitch API key.
const ClientIdEnvVar = "TWITCH_CLIENT_ID"
Probably not needed, but offered
const ClientIdHeader = "Client-ID"
const ClientSecretEnvVar = "TWITCH_CLIENT_SECRET"
Not used yet
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
func DefaultClient ¶
DefaultClient instantiates a new Twitch API client. This function requires the environment variables `TWITCH_ACCESS_TOKEN` and `TWITCH_CLIENT_ID` to be set and contain valid access token and client id, respectively, to authenticate with Twitch.
func NewClient ¶
NewClient creates a new API client with the given key and the default API endpoint. Twitch requires both an access token and a client id for requests, so we error if either is empty.
Creating an access token is not yet supported by this libary TODO: Support creating an access token
func (*Client) GetGames ¶
func (k *Client) GetGames(i *GetGamesInput) (*GetGamesOutput, error)
Gets details specific games. Can be list of games, ids See:
func (*Client) PostForm ¶
func (c *Client) PostForm(p string, i interface{}, ro *twitch.RequestOptions) (*http.Response, error)
PostForm issues an HTTP POST request with the given interface form-encoded.
func (*Client) PutForm ¶
func (c *Client) PutForm(p string, i interface{}, ro *twitch.RequestOptions) (*http.Response, error)
PutForm issues an HTTP PUT request with the given interface form-encoded.
func (*Client) RawRequest ¶
RawRequest accepts a verb, URL, and twitch.RequestOptions struct and returns the constructed http.Request and any errors that occurred
func (*Client) Request ¶
Request makes an HTTP request against the HTTPClient using the given verb, Path, and request options.
func (*Client) RequestForm ¶
func (c *Client) RequestForm(verb, p string, i interface{}, ro *twitch.RequestOptions) (*http.Response, error)
RequestForm makes an HTTP request with the given interface being encoded as form data.
type GetGamesInput ¶
type GetGamesInput struct { // Games are referenced by a globally unique string called a slug Names []string `mapstructure:"name"` Ids []int `mapstructure:"id"` }
GetGamesInput is the input to the GetGames function.
type GetGamesOutput ¶
type GetGamesOutput struct {
Games []*Game `mapstructure:"data"`
}
GetGamesOutput is the output of the GetGames function.