helix

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2022 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const BaseURL = "https://api.twitch.tv/helix"

BaseURL is the API path that will never change.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	ID string

	RateLimiter *RateLimiter
	Self        User
	// contains filtered or unexported fields
}

Client stores an API ClientID and OAuth Token

func New

func New(id, bearer string) *Client

New Helix API Client.

func (*Client) GetOwnUser

func (client *Client) GetOwnUser() (*User, error)

GetOwnUser retrieves a Twitch User object based on the clients OAuth Token.

func (*Client) GetStreams

func (client *Client) GetStreams(opts StreamOpts) (*StreamsData, error)

GetStreams retrieves a list of stream objects based on the specified StreamOpts.

func (*Client) GetUsers

func (client *Client) GetUsers(opts UserOpts) (*UsersData, error)

GetUsers retrieves a list of users based on the specified UserOpts.

func (*Client) Request

func (client *Client) Request(method, path string, body interface{}) (request.HTTPResponse, error)

Request Twitch Helix Endpoints and get an HTTP response back.

type IHelix

type IHelix interface {
	Request(string, string, interface{}) (request.HTTPResponse, error)

	GetOwnUser() (*User, error)
	GetUsers(UserOpts) (*UsersData, error)

	GetStreams(StreamOpts) (*StreamsData, error)
}

IHelix contains all methods available to the Helix API Client.

type IRateLimiter

type IRateLimiter interface {
	Enqueue(*request.HTTPRequest) (request.HTTPResponse, error)
	Close()
}

IRateLimiter contains all methods available to the RateLimiter.

type Pagination

type Pagination struct {
	Cursor string `json:"cursor"`
}

Pagination stores a cursor for the Twitch Helix API.

type RateLimiter

type RateLimiter struct {
	Bucket    int
	Remaining int
	Reset     time.Time
	// contains filtered or unexported fields
}

RateLimiter stores data used to keep track of the Twitch API Ratelimit.

func (*RateLimiter) Close

func (limiter *RateLimiter) Close()

Close frees resources used by the RateLimiter.

func (*RateLimiter) Enqueue

func (limiter *RateLimiter) Enqueue(req *request.HTTPRequest) (request.HTTPResponse, error)

Enqueue queues a HTTP request for when the Twitch API will allow it to go through.

type Stream

type Stream struct {
	ID           string   `json:"id"`
	UserID       string   `json:"user_id"`
	Login        string   `json:"user_name"`
	GameID       string   `json:"game_id"`
	Title        string   `json:"title"`
	ThumbnailURL string   `json:"thumbnail_url"`
	TagIDs       []string `json:"tag_ids"`
	Language     string   `json:"language"`
	ViewerCount  int      `json:"viewer_count"`
	Type         string   `json:"type"`
	StartedAt    string   `json:"started_at"`
}

Stream stores data about a livestream on Twitch.

type StreamOpts

type StreamOpts struct {
	First      int
	UserIDs    []string
	UserLogins []string
	GameIDs    []string
	Languages  []string
	After      Pagination
	Before     Pagination
}

StreamOpts stores options for requests to the Twitch Streams API.

type StreamsData

type StreamsData struct {
	Data       []Stream   `json:"data"`
	Pagination Pagination `json:"pagination"`
}

StreamsData stores a list of streams returned by the Twitch Streams API.

type User

type User struct {
	ID              string `json:"id"`
	Login           string `json:"login"`
	DisplayName     string `json:"display_name"`
	Description     string `json:"description"`
	ProfileImageURL string `json:"profile_image_url"`
	OfflineImageURL string `json:"offline_image_url"`
	Email           string `json:"email"`
	ViewCount       int    `json:"view_count"`
	BroadcasterType string `json:"broadcaster_type"`
	Type            string `json:"type"`
}

User stores data about a user on Twitch.

type UserOpts

type UserOpts struct {
	IDs    []string
	Logins []string
}

UserOpts stores options for requests to the Twitch Users API.

type UsersData

type UsersData struct {
	Data []User `json:"data"`
}

UsersData stores a list of users returned by the Twitch Users API.

Jump to

Keyboard shortcuts

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