twch

package module
v0.0.0-...-a61ee77 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2014 License: MIT Imports: 6 Imported by: 0

README

twch

Build Status GoDoc

Twch is an interface to the Twitch.tv API for the Go programming language.

Examples

Coming soon...

License

Twch is realeased under the MIT License. More info in the LICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Asset

type Asset struct {
	Large    *string `json:"large"`
	Medium   *string `json:"medium"`
	Small    *string `json:"small"`
	Template *string `json:"template"`
}

Asset represents links to images assets that are likely to come along with Game and Channel responses. Fields are pointer types to support empty responses from API results.

type Block

type Block struct {
	ID        *int    `json:"_id"`
	UpdatedAt *string `json:"updated_at"`
	User      *User   `json:"user"`
}

type Blocks

type Blocks struct {
	// contains filtered or unexported fields
}

func (*Blocks) AddBlock

func (b *Blocks) AddBlock(user, target string) (block *Block, resp *Response, err error)

AddBlock adds a block to the passed authenticated user. `user` is the current user, `target` is the account to block. A successful block returns the new block object. This method requires OAuth authentication with the required `user_blocks_edit` scope

func (*Blocks) ListBlocks

func (b *Blocks) ListBlocks(login string, opts *ListOptions) (blocks []Block, resp *Response, err error)

func (*Blocks) RemoveBlock

func (b *Blocks) RemoveBlock(user, target string) (err error)

RemoveBlock deletes a block from the passed authenticated user. `user` is the current user, `target` is the account to block. A 404 error will be returned if the block did not exist for the given user.

type Channel

type Channel struct {
	ID                           *int    `json:"_id,omitempty"`
	DisplayName                  *string `json:"display_name,omitempty"`
	Name                         *string `json:"name,omitempty"`
	Title                        *string `json:"title,omitempty"`
	Game                         *string `json:"game,omitempty"`
	Delay                        *int    `json:"delay,omitempty"`
	StreamKey                    *string `json:"stream_key,omitempty"`
	Teams                        []Team  `json:"teams,omitempty"`
	Status                       *string `json:"status,omitempty"`
	Banner                       *string `json:"banner,omitempty"`
	ProfileBanner                *string `json:"profile_banner,omitempty"`
	ProfileBannerBackgroundColor *string `json:"profile_banner_background_color,omitempty"`
	VideoBanner                  *string `json:"video_banner,omitempty"`
	Background                   *string `json:"background,omitempty"`
	URL                          *string `json:"url,omitempty"`
	Login                        *string `json:"login,omitempty"`
	Email                        *string `json:"email,omitempty"`
	Mature                       *bool   `json:"mature,omitempty"`
	Language                     *string `json:"language,omitempty"`
	BroadcasterLanguage          *string `json:"broadcaster_language,omitempty"`
	Partner                      *bool   `json:"partner,omitempty"`
	Views                        *int    `json:"views,omitempty"`
	Followers                    *int    `json:"followers,omitempty"`
	CreatedAt                    *string `json:"created_at,omitempty"`
	UpdatedAt                    *string `json:"updated_at,omitempty"`
}

type ChannelOptions

type ChannelOptions struct {
	Status string `url:"status,omitempty"`
	Game   string `url:"game,omitempty"`
	Delay  string `url:"deplay,omitempty"`
}

type Channels

type Channels struct {
	// contains filtered or unexported fields
}

func (*Channels) GetChannel

func (c *Channels) GetChannel(channel string) (ch *Channel, resp *Response, err error)

GetChannel returns a channel by name

func (*Channels) GetChannelFollowers

func (c *Channels) GetChannelFollowers(channel string) ([]Follow, error)

func (*Channels) GetUserChannel

func (c *Channels) GetUserChannel() (ch *Channel, resp *Response, err error)

GetUserChannel returns the channel for the authenticated user Requires the `channel_read` authentication scope to be approved

func (*Channels) ListChannelEditors

func (c *Channels) ListChannelEditors(channel string) (u []User, resp *Response, err error)

ListChannelEditors returns a list of user objects associated with the channel as "editor" status. This method requires the `channel_read` authentication scope

func (*Channels) ListChannelTeams

func (c *Channels) ListChannelTeams(channel string) (t []Team, resp *Response, err error)

ListChannelTeams returns a list of teams for the given channel

func (*Channels) ResetStreamKey

func (c *Channels) ResetStreamKey(channel string) (err error)

ResetStreamKey reset's an authenticated channel's stream key Requires the `channel_stream` authentication scope

func (*Channels) StartCommercial

func (c *Channels) StartCommercial(channel string) error

func (*Channels) UpdateChannel

func (c *Channels) UpdateChannel(channel string) error

type Chats

type Chats struct {
	// contains filtered or unexported fields
}

func (*Chats) ListEmoticons

func (c *Chats) ListEmoticons() (e []Emoticon, resp *Response, err error)

ListEmoticons returns a list of all the emoticons on Twitch

type Client

type Client struct {
	ID string

	BaseUrl *url.URL

	Blocks        *Blocks
	Channels      *Channels
	Chat          *Chats
	Games         *Games
	Ingests       *Ingests
	Search        *Search
	Streams       *Streams
	Subscriptions *Subscriptions
	Teams         *Teams
	Users         *Users
	Videos        *Videos
	// contains filtered or unexported fields
}

func NewClient

func NewClient(id string, c *http.Client) (client *Client, err error)

NewClient constructs a new client to interface with the Twitch API

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (r *Response, err error)

Do performs the http request and marshals the response JSON into the past `v` interface type.

func (*Client) NewRequest

func (c *Client) NewRequest(method, uri string) (req *http.Request, err error)

NewRequest constructs a valid http.Request object for Twitch requests

type CommericalOptions

type CommericalOptions struct {
	Length string `url:"length,omitempty"`
}

type Emoticon

type Emoticon struct {
	Regex  *string         `json:"regex"`
	Images []EmoticonImage `json:"images"`
}

type EmoticonImage

type EmoticonImage struct {
	EmoticonSet *int    `json:"emoticon_set,omitempty"`
	Height      *int    `json:"height,omitempty"`
	Width       *int    `json:"width,omitempty"`
	URL         *string `json:"url,omitempty"`
}

type FeaturedStream

type FeaturedStream struct {
	Image  *string `json:"image,omitempty"`
	Text   *string `json:"text,omitempty"`
	Stream *Stream `json:"stream,omitempty"`
}

type Follow

type Follow struct {
	User      User   `json:"user,omitempty"`
	CreatedAt string `json:"created_at,omitempty"`
}

type FollowOptions

type FollowOptions struct {
	Direction string `url:"direction,omitempty"`
	RequestOptions
}

type Game

type Game struct {
	Name        *string `json:"name" `
	Box         *Asset  `json:"box"`
	GiantbombId *int    `json:"giantbomb_id"`
	Popularity  *int    `json:"popularity,omitempty"`
	Viewers     *int
	Channels    *int
}

type Games

type Games struct {
	// contains filtered or unexported fields
}

func (*Games) ListTop

func (g *Games) ListTop(opts *RequestOptions) (games []Game, resp *Response, err error)

Top lists games sorted by number of current viewers on Twitch, most popular first

type Ingest

type Ingest struct {
	Name         *string  `json:"name,omitempty"`
	Default      *bool    `json:"default,omitempty"`
	ID           *int     `json:"_id,omitempty"`
	URLTemplate  *string  `json:"url_template,omitempty"`
	Availability *float32 `json:"availability,omitempty"`
}

type Ingests

type Ingests struct {
	// contains filtered or unexported fields
}

func (*Ingests) ListIngests

func (i *Ingests) ListIngests() (ingests []Ingest, resp *Response, err error)

type ListOptions

type ListOptions struct {
	Limit  int `url:"limit,omitempty"`
	Offset int `url:"offset,omitempty"`
}

type RequestOptions

type RequestOptions struct {
	HLS bool `url:"hls,omitempty"`
	ListOptions
}

RequestOptions is the base query parameters used for customizing query output from List queries.

type Response

type Response struct {
	NextOffset *int
	PrevOffset *int
	Total      *int
	*http.Response
}

Response augments http.Response to include extra meta data for List query responses. Fields are pointer types to support response inconsistencies in Twitch's API, since some endpoints allow pagination, but don't include a total count, etc.

func (*Response) SetOffsets

func (r *Response) SetOffsets(p listPageOptions) (err error)

SetOffsets adds the paging metadata to the response

func (*Response) SetTotal

func (r *Response) SetTotal(t listTotalOptions)

SetTotal adds the total list count to the response

type Search struct {
	// contains filtered or unexported fields
}

func (*Search) Channels

func (s *Search) Channels(q string, opts *ListOptions) (ch []Channel, resp *Response, err error)

Channels returns a list of channels matching the search query

func (*Search) Games

func (s *Search) Games(q string, live bool) (g []Game, resp *Response, err error)

Games returns a list of games matching the search query

func (*Search) Streams

func (s *Search) Streams(q string, opts *RequestOptions) (st []Stream, resp *Response, err error)

Streams returns a list of streams matching the search query

type Stream

type Stream struct {
	ID        *int     `json:"_id,omitempty"`
	Viewers   *int     `json:"viewers,omitempty"`
	CreatedAt *string  `json:"created_at,omitempty"`
	Preview   *Asset   `json:"preview,omitempty"`
	Channel   *Channel `json:"channel,omitempty"`
	Game      *string  `json:"game,omitempty"`
}

type StreamOptions

type StreamOptions struct {
	Game       string `url:"game,omitempty"`
	Channel    string `url:"channel,omitempty"`
	Embeddable bool   `url:"embeddable,omitempty"`
	ClientID   string `url:"client_id,omitempty"`
	RequestOptions
}

type StreamSummary

type StreamSummary struct {
	Viewers  int `json:"viewers,omitempty"`
	Channels int `json:"channels,omitempty"`
}

type Streams

type Streams struct {
	// contains filtered or unexported fields
}

func (*Streams) GetStream

func (s *Streams) GetStream(channel string) (stream *Stream, resp *Response, err error)

GetStream returns a channel's stream, if live.

If the channel is offline, a zeroed Stream is returned without error.

func (*Streams) GetSummary

func (s *Streams) GetSummary() (summary *StreamSummary, resp *Response, err error)

Summary returns viewership and channel count for all streams currently on Twitch

func (*Streams) ListFeaturedStreams

func (s *Streams) ListFeaturedStreams(opts *RequestOptions) (f []FeaturedStream, resp *Response, err error)

ListFeaturedStreams returns the streams featured on the front page of twitch

func (*Streams) ListStreams

func (s *Streams) ListStreams(opts *StreamOptions) (streams []Stream, resp *Response, err error)

ListStreams lists all the current streams on Twitch

type Subscription

type Subscription struct {
	ID        *string  `json:"_id,omitempty"`
	User      *User    `json:"user,omitempty"`
	Channel   *Channel `json:"channel,omitempty"`
	CreatedAt *string  `json:"created_at,omitempty"`
}

type SubscriptionOptions

type SubscriptionOptions struct {
	Direction string `url:"direction,omitempty"`
	ListOptions
}

type Subscriptions

type Subscriptions struct {
	// contains filtered or unexported fields
}

func (*Subscriptions) GetChannelSubscriptions

func (s *Subscriptions) GetChannelSubscriptions(channel string, opts *SubscriptionOptions) (sub []Subscription, resp *Response, err error)

GetChannelSubscriptions returns a list of subscriptions for the given channel, ordered by creation date. Requires the `channel_subscriptions` authentication scope.

func (*Subscriptions) GetSubscribedChannel

func (s *Subscriptions) GetSubscribedChannel(user, channel string) (sub *Subscription, resp *Response, err error)

ChannelSubscribed returns a subscription with a channel that the user subscribes to. Requires the `user_subscriptions` authentication scope for the given user.

func (*Subscriptions) GetUserSubscribed

func (s *Subscriptions) GetUserSubscribed(channel, user string) (sub *Subscription, resp *Response, err error)

UserSubscribed returns a subscription if the user is subscribed to the given channel. Requires the `channel_check_subscription` authentication scope for the given channel.

type Team

type Team struct {
	ID          *int    `json:"_id,omitempty"`
	Name        *string `json:"name,omitempty"`
	Info        *string `json:"info,omitempty"`
	DisplayName *string `json:"display_name,omitempty"`
	Banner      *string `json:"banner,omitempty"`
	Background  *string `json:"background,omitempty"`
	CreatedAt   *string `json:"created_at,omitempty"`
	UpdatedAt   *string `json:"updated_at,omitempty"`
}

type Teams

type Teams struct {
	// contains filtered or unexported fields
}

func (*Teams) GetTeam

func (t *Teams) GetTeam(team string) (r *Team, resp *Response, err error)

GetTeam returns a team for the passed team name

func (*Teams) ListTeams

func (t *Teams) ListTeams() (teams []Team, resp *Response, err error)

ListTeams returns a list of teams that are active on Twitch

type User

type User struct {
	ID          *int    `json:"_id,omitempty"`
	Type        *string `json:"type,omitempty"`
	Name        *string `json:"name,omitempty"`
	DisplayName *string `json:"display_name,omitempty"`
	Bio         *string `json:"bio,omitempty"`
	CreatedAt   *string `json:"created_at,omitempty"`
	UpdatedAt   *string `json:"updated_at,omitempty"`
	Email       *string `json:"email,omitempty"`
	Partnered   *bool   `json:"partnered,omitempty"`
	Staff       *bool   `json:"staff,omitempty"`
}

type Users

type Users struct {
	// contains filtered or unexported fields
}

func (*Users) FollowChannel

func (u *Users) FollowChannel(user, channel string) (ch *Channel, resp *Response, err error)

func (*Users) GetCurrentUser

func (u *Users) GetCurrentUser() (user *User, resp *Response, err error)

GetCurrentUser returns the authenticated user with email and partner info. Requires the `user_read` authentication scope.

func (*Users) GetUser

func (u *Users) GetUser(username string) (user *User, resp *Response, err error)

GetUser returns the public profile of a given Twitch user

func (*Users) IsFollowing

func (u *Users) IsFollowing(user, channel string) (ch *Channel, resp *Response, err error)

func (*Users) ListFollowedChannels

func (u *Users) ListFollowedChannels(user string) (ch []Channel, resp *Response, err error)

func (*Users) ListFollowedStreams

func (u *Users) ListFollowedStreams(opts *RequestOptions) (s []Stream, resp *Response, err error)

ListFollowedStreams returns a list of the streams the authenticated user follows. Requires the `user_read` authentication scope.

func (*Users) ListFollowedVideos

func (u *Users) ListFollowedVideos(opts *ListOptions) (videos []Video, resp *Response, err error)

ListFollowedVideos returns a list of videos created by channels the authenticated user is following. Requires the `user_read` authentication scope.

func (*Users) UnfollowChannel

func (u *Users) UnfollowChannel(user, channel string) (err error)

type Video

type Video struct {
	ID          *string  `json:"_id"`
	Title       *string  `json:"title"`
	URL         *string  `json:"url"`
	Views       *int     `json:"views"`
	Description *string  `json:"description"`
	Length      *int     `json:"length"`
	Game        *string  `json:"game"`
	Preview     *string  `json:"preview"`
	RecordedAt  *string  `json:"recorded_at"`
	Channel     *Channel `json:"channel"`
}

type VideoChannelOptions

type VideoChannelOptions struct {
	Broadcasts bool `url:"broadcasts,omitempty"`
	ListOptions
}

type VideoRequestOptions

type VideoRequestOptions struct {
	Game   string `url:"game,omitempty"`
	Period string `url:"period,omitempty"`
	ListOptions
}

type Videos

type Videos struct {
	// contains filtered or unexported fields
}

func (*Videos) GetVideo

func (v *Videos) GetVideo(id int) (video *Video, resp *Response, err error)

GetVideo returns a video object via its ID

func (*Videos) ListChannelVideos

func (v *Videos) ListChannelVideos(channel string, opts *VideoChannelOptions) (videos []Video, resp *Response, err error)

ListChannelVideos returns videos belonging to the target channel. Only broadcasts will be returned when the `VideoChannelOptions.Broadcasts` field is true. Otherwise only highlights are returned by default.

func (*Videos) ListTop

func (v *Videos) ListTop(opts *VideoRequestOptions) (videos []Video, resp *Response, err error)

ListTop returns a list of the top videos on twitch for the specified period of time, ordered by most popular first. Defined time periods are "week", "month", or "all". By default, the top videos of the "week" are returned. Videos belonging to a specific game can be returned by passing the name of the game in the `Game` VideoRequestOption value. Otherwise, all games will be included in the result.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL