twitch

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

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

Go to latest
Published: Jun 28, 2020 License: MIT Imports: 12 Imported by: 0

README

Twitch API

Very limited twitch API implementation

Testing

TWITCH_LOGIN=<your username> TWITCH_CLIENT_ID=<client id> TWITCH_CLIENT_SECRET=<client secret> go test -v

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StructToQuery

func StructToQuery(s interface{}) (query *url.Values, err error)

func ZipQuery

func ZipQuery(args ...interface{}) (query *url.Values, err error)

Types

type API

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

func New

func New(ctx context.Context, cfg Config) (api *API, err error)

func (*API) GetStreams

func (api *API) GetStreams(sr StreamsRequest) (streams []Stream, data DataResponse, err error)

func (*API) GetUsers

func (api *API) GetUsers(ur UsersRequest) (users []User, data DataResponse, err error)

func (*API) GetUsersFollows

func (api *API) GetUsersFollows(ufr UsersFollowsRequest) (follows []UsersFollows, data DataResponse, err error)

func (*API) NewRequest

func (api *API) NewRequest(path string, method string, body io.Reader) (req *http.Request, err error)

type Config

type Config struct {
	ClientID     string
	ClientSecret string
	Scopes       []string
}

type DataResponse

type DataResponse struct {
	Data       interface{} `json:"data"`
	Pagination Pagination  `json:"pagination"`
	Total      int         `json:"total"`
}

type Pagination

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

type Stream

type Stream struct {
	ID           string    `json:"id"`
	UserID       string    `json:"user_id"`
	UserName     string    `json:"user_name"`
	GameID       string    `json:"game_id"`
	Type         string    `json:"type"`
	Title        string    `json:"title"`
	ViewerCount  int       `json:"viewer_count"`
	StartedAt    time.Time `json:"started_at"`
	Language     string    `json:"language"`
	ThumbnailURL string    `json:"thumbnail_url"`
}

type StreamsRequest

type StreamsRequest struct {
	After     string   `query:"after"`
	Before    string   `query:"before"`
	First     int      `query:"first"`
	GameID    []string `query:"game_id"`
	Language  string   `query:"language"`
	UserID    []string `query:"user_id"`
	UserLogin []string `query:"user_login"`
}

type User

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

type UsersFollows

type UsersFollows struct {
	FollowedAt time.Time `json:"followed_at"`
	FromID     string    `json:"from_id"`
	FromName   string    `json:"from_name"`
	ToID       string    `json:"to_id"`
	ToName     string    `json:"to_name"`
}

type UsersFollowsRequest

type UsersFollowsRequest struct {
	After  string `query:"after"`
	First  int    `query:"first"`
	FromID string `query:"from_id"`
	ToID   string `query:"to_id"`
}

type UsersRequest

type UsersRequest struct {
	ID    string `query:"id"`
	Login string `query:"login"`
}

Jump to

Keyboard shortcuts

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