Documentation
¶
Overview ¶
Package fpl is the library behind the fpl command line: the HTTP client, request shaping, and the typed data models for the Fantasy Premier League public API.
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 API throws under load.
Index ¶
- Constants
- type Client
- func (c *Client) BootstrapStatic(ctx context.Context) ([]Player, []Team, []Gameweek, error)
- func (c *Client) Entry(ctx context.Context, id int) (*wireEntry, error)
- func (c *Client) Fixtures(ctx context.Context, gw int) ([]Fixture, error)
- func (c *Client) Get(ctx context.Context, url string) ([]byte, error)
- func (c *Client) LeagueStandings(ctx context.Context, id int) (string, []StandingEntry, error)
- func (c *Client) PlayerSummary(ctx context.Context, id int) ([]PlayerHistory, error)
- type Config
- type Domain
- type Fixture
- type Gameweek
- type Player
- type PlayerHistory
- type StandingEntry
- type Team
Constants ¶
const BaseURL = "https://" + Host
BaseURL is the root every request is built from.
const DefaultUserAgent = "fpl/dev (+https://github.com/tamnd/fpl-cli)"
DefaultUserAgent identifies the client to FPL.
const Host = "fantasy.premierleague.com"
Host is the Fantasy Premier League API host.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
HTTP *http.Client
UserAgent string
// Rate is the minimum gap between requests. Zero means no pacing.
Rate time.Duration
Retries int
// contains filtered or unexported fields
}
Client talks to the FPL API over HTTP.
func (*Client) BootstrapStatic ¶
BootstrapStatic fetches the large bootstrap-static payload and returns players, teams, and gameweeks.
func (*Client) Fixtures ¶
Fixtures fetches fixtures for a given gameweek. It also fetches bootstrap to resolve team IDs to names.
func (*Client) Get ¶
Get fetches url and returns the response body. It paces and retries according to the client's settings.
func (*Client) LeagueStandings ¶
LeagueStandings fetches standings for a classic league by ID.
func (*Client) PlayerSummary ¶
PlayerSummary fetches the gameweek history for a player by element ID.
type Domain ¶
type Domain struct{}
Domain is the fpl driver.
func (Domain) Classify ¶
Classify turns an accepted input into (uriType, id). Numeric string → "player"; "gw:" prefix → "gameweek"; "l:" prefix → "league".
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, hostnames, and binary identity.
type Fixture ¶
type Fixture struct {
TeamHome string `json:"team_home"`
TeamAway string `json:"team_away"`
ScoreHome int `json:"score_home"`
ScoreAway int `json:"score_away"`
Finished bool `json:"finished"`
KickoffTime string `json:"kickoff_time"`
}
Fixture is one match in a gameweek.
type Gameweek ¶
type Gameweek struct {
ID int `kit:"id" json:"id"`
Name string `json:"name"`
DeadlineTime string `json:"deadline_time"`
Finished bool `json:"finished"`
IsCurrent bool `json:"is_current"`
AverageScore int `json:"average_score"`
HighestScore int `json:"highest_score"`
}
Gameweek is one FPL event.
type Player ¶
type Player struct {
ID int `kit:"id" json:"id"`
Name string `json:"name"`
FullName string `json:"full_name"`
TeamID int `json:"team_id"`
Price float64 `json:"price"`
TotalPoints int `json:"total_points"`
Form string `json:"form"`
SelectedBy string `json:"selected_by"`
}
Player is one FPL element (player).
type PlayerHistory ¶
type PlayerHistory struct {
Round int `json:"round"`
Points int `json:"points"`
Minutes int `json:"minutes"`
Goals int `json:"goals_scored"`
Assists int `json:"assists"`
CleanSheets int `json:"clean_sheets"`
}
PlayerHistory is one gameweek's performance for a player.