Documentation
¶
Overview ¶
Package goff provides a basic Yahoo Fantasy Sports API client.
This package is designed to facilitate communication with the Yahoo Fantasy Sports API. The steps required to get a new client up and running are as follows:
- Obtain an API key for your application. See https://developer.apps.yahoo.com/dashboard/createKey.html
- Call goff.GetConsumer(clientID, clientSecret) using your client's information.
- Use oauth.Consumer to obtain an oauth.AccessToken. See https://godoc.org/github.com/mrjones/oauth
- Call goff.NewOAuthClient(consumer, accessToken) with the consumer and access token.
- Use the returned client to make direct API requests with GetFantasyContent(url) or through one of the convenience methods. See http://developer.yahoo.com/fantasysports/guide/ for the type requests that can be made.
The goff client is currently in early stage development and the API is subject to change at any moment.
Index ¶
- Constants
- func GetConsumer(clientID string, clientSecret string) *oauth.Consumer
- func NewLRUCache(clientID string, duration time.Duration, cache *lru.LRUCache) *lruCache
- type Cache
- type Client
- func (c *Client) GetAllTeamStats(leagueKey string, week int) ([]Team, error)
- func (c *Client) GetAllTeams(leagueKey string) ([]Team, error)
- func (c *Client) GetFantasyContent(url string) (*FantasyContent, error)
- func (c *Client) GetLeagueMetadata(leagueKey string) (*League, error)
- func (c *Client) GetPlayersStats(leagueKey string, week int, players []Player) ([]Player, error)
- func (c *Client) GetTeam(teamKey string) (*Team, error)
- func (c *Client) GetTeamRoster(teamKey string, week int) ([]Player, error)
- func (c *Client) GetUserLeagues(year string) ([]League, error)
- func (c *Client) RequestCount() int
- type ContentProvider
- type FantasyContent
- type Game
- type League
- type Manager
- type Matchup
- type Name
- type OAuthConsumer
- type Player
- type Points
- type Record
- type Roster
- type SelectedPosition
- type Team
- type TeamLogo
- type TeamStandings
- type User
Constants ¶
const ( // NflGameKey represents the current year's Yahoo fantasy football game NflGameKey = "nfl" // YahooBaseURL is the base URL for all calls to Yahoo's fantasy sports API YahooBaseURL = "http://fantasysports.yahooapis.com/fantasy/v2" // YahooRequestTokenURL is used to create OAuth request tokens YahooRequestTokenURL = "https://api.login.yahoo.com/oauth/v2/get_request_token" // YahooAuthTokenURL is used to create OAuth authorization tokens YahooAuthTokenURL = "https://api.login.yahoo.com/oauth/v2/request_auth" // YahooGetTokenURL is used to get the OAuth access token used when making // calls to the fantasy sports API. YahooGetTokenURL = "https://api.login.yahoo.com/oauth/v2/get_token" )
Variables ¶
This section is empty.
Functions ¶
func GetConsumer ¶
GetConsumer generates an OAuth Consumer for the Yahoo fantasy sports API
Types ¶
type Cache ¶ added in v0.2.0
type Cache interface {
Set(url string, time time.Time, content *FantasyContent)
Get(url string, time time.Time) (content *FantasyContent, ok bool)
}
Cache sets and retrieves fantasy content for request URLs based on the time for which the content was valid
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an application authorized to use the Yahoo fantasy sports API.
func NewCachedOAuthClient ¶ added in v0.2.0
func NewCachedOAuthClient( cache Cache, consumer OAuthConsumer, accessToken *oauth.AccessToken) *Client
NewCachedOAuthClient creates a new OAuth client that checks and updates the given Cache when retrieving fantasy content.
See NewLRUCache
func NewOAuthClient ¶
func NewOAuthClient(consumer OAuthConsumer, accessToken *oauth.AccessToken) *Client
NewOAuthClient creates a Client that uses oauth authentication to communicate with the Yahoo fantasy sports API. The consumer can be created with `GetConsumer` and then used to obtain the access token passed in here.
func (*Client) GetAllTeamStats ¶
GetAllTeamStats gets teams stats for a given week.
func (*Client) GetAllTeams ¶
GetAllTeams returns all teams playing in the given league.
func (*Client) GetFantasyContent ¶
func (c *Client) GetFantasyContent(url string) (*FantasyContent, error)
GetFantasyContent directly access Yahoo fantasy resources.
See http://developer.yahoo.com/fantasysports/guide/ for more information
func (*Client) GetLeagueMetadata ¶
GetLeagueMetadata returns the metadata associated with the given league.
func (*Client) GetPlayersStats ¶
GetPlayersStats returns a list of Players containing their stats for the given week in the given year.
func (*Client) GetTeamRoster ¶
GetTeamRoster returns a team's roster for the given week.
func (*Client) GetUserLeagues ¶
GetUserLeagues returns a list of the current user's leagues for the given year.
func (*Client) RequestCount ¶
RequestCount returns the amount of requests made to the Yahoo API on behalf of the application represented by this Client.
type ContentProvider ¶
type ContentProvider interface {
Get(url string) (content *FantasyContent, err error)
// The amount of requests made to the Yahoo API on behalf of the application
// represented by this Client.
RequestCount() int
}
ContentProvider returns the data from an API request.
type FantasyContent ¶
type FantasyContent struct {
XMLName xml.Name `xml:"fantasy_content"`
League League `xml:"league"`
Team Team `xml:"team"`
Users []User `xml:"users>user"`
}
FantasyContent is the root level response containing the data from a request to the fantasy sports API.
type Game ¶
type Game struct {
Leagues []League `xml:"leagues>league"`
}
Game represents a single year in the Yahoo fantasy football ecosystem. It consists of zero or more leagues.
type League ¶
type League struct {
LeagueKey string `xml:"league_key"`
LeagueID uint64 `xml:"league_id"`
Name string `xml:"name"`
Players []Player `xml:"players>player"`
Teams []Team `xml:"teams>team"`
CurrentWeek int `xml:"current_week"`
StartWeek int `xml:"start_week"`
EndWeek int `xml:"end_week"`
IsFinished bool `xml:"is_finished"`
}
A League is a uniquely identifiable group of players and teams. The scoring system, roster details, and other metadata can differ between leagues.
type Manager ¶
type Manager struct {
ManagerID uint64 `xml:"manager_id"`
Nickname string `xml:"nickname"`
Guid string `xml:"guid"`
IsCurrentLogin bool `xml:"is_current_login"`
}
A Manager is a user in change of a given team.
type OAuthConsumer ¶
type OAuthConsumer interface {
Get(url string, data map[string]string, token *oauth.AccessToken) (*http.Response, error)
}
OAuthConsumer returns data from an oauth provider
type Player ¶
type Player struct {
PlayerKey string `xml:"player_key"`
PlayerID uint64 `xml:"player_id"`
Name Name `xml:"name"`
DisplayPosition string `xml:"display_position"`
ElligiblePositions []string `xml:"elligible_positions>position"`
SelectedPosition SelectedPosition `xml:"selected_position"`
PlayerPoints Points `xml:"player_points"`
}
A Player is a single player for the given sport.
type Points ¶
type Points struct {
CoverageType string `xml:"coverage_type"`
Season string `xml:"season"`
Week int `xml:"week"`
Total float64 `xml:"total"`
}
Points represents scoring statistics for a time period specified by CoverageType.
type Roster ¶
type Roster struct {
CoverageType string `xml:"coverage_type"`
Players []Player `xml:"players>player"`
Week int `xml:"week"`
}
A Roster is the set of players belonging to one team for a given week.
type SelectedPosition ¶
type SelectedPosition struct {
CoverageType string `xml:"coverage_type"`
Week int `xml:"week"`
Position string `xml:"position"`
}
SelectedPosition is the position chosen for a Player for a given week.
type Team ¶
type Team struct {
TeamKey string `xml:"team_key"`
TeamID uint64 `xml:"team_id"`
Name string `xml:"name"`
URL string `xml:"url"`
TeamLogos []TeamLogo `xml:"team_logos>team_logo"`
IsOwnedByCurrentLogin bool `xml:"is_owned_by_current_login"`
WavierPriority int `xml:"waiver_priority"`
NumberOfMoves int `xml:"number_of_moves"`
NumberOfTrades int `xml:"number_of_trades"`
Managers []Manager `xml:"managers>manager"`
Matchups []Matchup `xml:"matchups>matchup"`
Roster Roster `xml:"roster"`
TeamPoints Points `xml:"team_points"`
TeamProjectedPoints Points `xml:"team_projected_points"`
TeamStandings TeamStandings `xml:"team_standings"`
Players []Player `xml:"players>player"`
}
A Team is a participant in exactly one league.

