Documentation
¶
Overview ¶
Package speedrun is the library behind the speedrun command line: the HTTP client, request shaping, and typed data models for speedrun.com.
The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries the transient failures (429 and 5xx) that any public site throws under load.
Index ¶
- Constants
- type Category
- type Client
- func (c *Client) Get(ctx context.Context, url string) ([]byte, error)
- func (c *Client) GetLeaderboard(ctx context.Context, gameID, categoryID string, top int) ([]*LeaderboardEntry, error)
- func (c *Client) ListCategories(ctx context.Context, gameID string) ([]*Category, error)
- func (c *Client) ListGames(ctx context.Context, search string, limit int) ([]*Game, error)
- func (c *Client) ListRuns(ctx context.Context, gameID string, limit int) ([]*Run, error)
- type Domain
- type Game
- type LeaderboardEntry
- type Run
Constants ¶
const BaseURL = "https://www.speedrun.com/api/v1"
BaseURL is the root every API request is built from.
const DefaultUserAgent = "speedrun-cli/0.1 (tamnd87@gmail.com)"
DefaultUserAgent identifies this client honestly.
const Host = "www.speedrun.com"
Host is the site this client talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Category ¶
type Category struct {
ID string `json:"id"`
Name string `json:"name"`
WebLink string `json:"weblink"`
Type string `json:"type"`
}
Category is a single run category for a game.
type Client ¶
type Client struct {
HTTP *http.Client
UserAgent string
BaseURL string
// Rate is the minimum gap between requests.
Rate time.Duration
Retries int
// contains filtered or unexported fields
}
Client talks to speedrun.com API over HTTP.
func (*Client) GetLeaderboard ¶
func (c *Client) GetLeaderboard(ctx context.Context, gameID, categoryID string, top int) ([]*LeaderboardEntry, error)
GetLeaderboard fetches the leaderboard for a game and category.
func (*Client) ListCategories ¶
ListCategories fetches all categories for a game.
type Domain ¶
type Domain struct{}
Domain is the speedrun.com driver.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, hostnames, and binary identity.
type Game ¶
type Game struct {
ID string `json:"id"`
Name string `json:"name"`
WebLink string `json:"weblink"`
Released int `json:"released"`
}
Game is a single speedrun.com game record.