Title: | API Client for Fantasy Football League Platforms |
---|---|
Description: | Helps access various Fantasy Football APIs by handling authentication and rate-limiting, forming appropriate calls, and returning tidy dataframes which can be easily connected to other data sources. |
Authors: | Tan Ho [aut, cre], Tony ElHabr [ctb], Joe Sydlowski [ctb] |
Maintainer: | Tan Ho <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.4.8.20 |
Built: | 2024-11-01 05:40:56 UTC |
Source: | https://github.com/ffverse/ffscrapr |
This function will reset the cache for any and all ffscrapr cached functions, as well as nflreadr's cached functions.
clear_cache()
clear_cache()
Applies some regex to clean html tags from strings. This is useful for platforms such as MFL that interpret HTML in their franchise name fields.
dp_clean_html(names)
dp_clean_html(names)
names |
a character (or character vector) |
a character vector of cleaned strings
c( "<b><font color= Cyan>Kevin OBrien (@kevinobrienff) </FONT></B>", "<em><font color= Purple> Other fun names</font></em>" ) %>% dp_clean_html()
c( "<b><font color= Cyan>Kevin OBrien (@kevinobrienff) </FONT></B>", "<em><font color= Purple> Other fun names</font></em>" ) %>% dp_clean_html()
Applies some name-cleaning heuristics to facilitate joins. These heuristics may include:
removing periods and apostrophes
removing common suffixes, such as Jr, Sr, II, III, IV
converting to lowercase
using ffscrapr::dp_name_mapping
to do common name substitutions, such as Mitch Trubisky to Mitchell Trubisky
dp_clean_names(...) dp_cleannames(...)
dp_clean_names(...) dp_cleannames(...)
... |
Arguments passed on to
|
Equivalent to the operation done by ffscrapr::dp_clean_names()
and uses the same player name database.
a character vector of cleaned names
nflreadr::clean_player_names()
dp_cleannames(c("A.J. Green", "Odell Beckham Jr.", "Le'Veon Bell Sr.")) dp_cleannames(c("Trubisky, Mitch", "Atwell, Chatarius", "Elliott, Zeke", "Elijah Moore"), convert_lastfirst = TRUE, use_name_database = TRUE )
dp_cleannames(c("A.J. Green", "Odell Beckham Jr.", "Le'Veon Bell Sr.")) dp_cleannames(c("Trubisky, Mitch", "Atwell, Chatarius", "Elliott, Zeke", "Elijah Moore"), convert_lastfirst = TRUE, use_name_database = TRUE )
Fetches a copy of the latest DynastyProcess player IDs csv
dp_playerids()
dp_playerids()
a tibble of player IDs
https://github.com/DynastyProcess/data
try( # try only shown here because sometimes CRAN checks are weird dp_playerids() )
try( # try only shown here because sometimes CRAN checks are weird dp_playerids() )
Fetches a copy of the latest DynastyProcess dynasty trade values sheets
dp_values(file = c("values.csv", "values-players.csv", "values-picks.csv"))
dp_values(file = c("values.csv", "values-players.csv", "values-picks.csv"))
file |
one of |
a tibble of trade values from DynastyProcess
https://github.com/DynastyProcess/data
try( # try only shown here because sometimes CRAN checks are weird dp_values() )
try( # try only shown here because sometimes CRAN checks are weird dp_values() )
This function creates a connection object which stores parameters and a user ID if available.
espn_connect( season = NULL, league_id = NULL, swid = NULL, espn_s2 = NULL, user_agent = NULL, rate_limit = TRUE, rate_limit_number = NULL, rate_limit_seconds = NULL, ... )
espn_connect( season = NULL, league_id = NULL, swid = NULL, espn_s2 = NULL, user_agent = NULL, rate_limit = TRUE, rate_limit_number = NULL, rate_limit_seconds = NULL, ... )
season |
Season to access on Fleaflicker - if missing, will guess based on system date (current year if March or later, otherwise previous year) |
league_id |
League ID |
swid |
SWID parameter for accessing private leagues - see vignette for details |
espn_s2 |
ESPN_S2 parameter for accessing private leagues - see vignette for details |
user_agent |
User agent to self-identify (optional) |
rate_limit |
TRUE by default - turn off rate limiting with FALSE |
rate_limit_number |
number of calls per |
rate_limit_seconds |
number of seconds as denominator for rate_limit |
... |
other arguments (for other methods, for R compat) |
a list that stores ESPN connection objects
conn <- espn_connect( season = 2018, league_id = 1178049, espn_s2 = Sys.getenv("TAN_ESPN_S2"), swid = Sys.getenv("TAN_SWID") )
conn <- espn_connect( season = 2018, league_id = 1178049, espn_s2 = Sys.getenv("TAN_ESPN_S2"), swid = Sys.getenv("TAN_SWID") )
This function is used to call the ESPN Fantasy API for league-based endpoints.
espn_getendpoint(conn, ..., x_fantasy_filter = NULL)
espn_getendpoint(conn, ..., x_fantasy_filter = NULL)
conn |
a connection object created by |
... |
Arguments which will be passed as "argumentname = argument" in an HTTP query parameter |
x_fantasy_filter |
a JSON-encoded character string that specifies a filter for the data |
The ESPN Fantasy API is undocumented and this should be used by advanced users familiar with the API.
It chooses the correct league endpoint based on the year (eg leagueHistory for <2018), checks the x_fantasy_filter for valid JSON input, builds a url with any optional query parameters, and executes the request with authentication and rate limiting.
HTTP query parameters (i.e. arguments to ...) are Case Sensitive.
Please see the vignette for more on usage.
A list object containing the query, response, and parsed content.
vignette("espn_getendpoint")
espn_getendpoint_raw
This function is the lower-level function that powers the API call: it takes a URL and headers and executes the http request with rate-limiting and authentication. It checks for JSON return and any warnings/errors, parses the json, and returns an espn_api object with the parsed content, the raw response, and the actual query.
espn_getendpoint_raw(conn, url_query, ...)
espn_getendpoint_raw(conn, url_query, ...)
conn |
a connection object created by ff_connect or equivalent - used for authentication |
url_query |
a fully-formed URL to call |
... |
any headers or other httr request objects to pass along |
object of class espn_api with parsed content, request, and response
espn_getendpoint()
- a higher level wrapper that checks JSON and prepares the url query
vignette("espn_getendpoint")
A cached table of ESPN NFL players. Will store in memory for each session! (via memoise in zzz.R)
espn_players(conn = NULL, season = NULL)
espn_players(conn = NULL, season = NULL)
conn |
a connection object created by |
season |
a season to fetch |
a dataframe containing all ~2000+ active players in the ESPN database
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect(season = 2020, league_id = 1178049) espn_players(conn, season = 2020) }) # end try
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect(season = 2020, league_id = 1178049) espn_players(conn, season = 2020) }) # end try
This function calculates the optimal starters for a given week, using some lineup heuristics.
espn_potentialpoints(conn, weeks = 1:17)
espn_potentialpoints(conn, weeks = 1:17)
conn |
the list object created by |
weeks |
a numeric vector for determining which weeks to calculate |
a tibble with the best lineup for each team and whether they were started or not
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect(season = 2021, league_id = 950665) espn_potentialpoints(conn, weeks = 1) }) # end try
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect(season = 2021, league_id = 950665) espn_potentialpoints(conn, weeks = 1) }) # end try
This function creates a connection object which stores parameters and gets a login-cookie if available - it does so by passing arguments to the appropriate league-based handler.
ff_connect(platform = "mfl", league_id = NULL, ...)
ff_connect(platform = "mfl", league_id = NULL, ...)
platform |
one of MFL or Sleeper (Fleaflicker, ESPN, Yahoo in approximate priority order going forward) |
league_id |
league_id (currently assuming one league at a time) |
... |
other parameters passed to the connect function for each specific platform. |
a connection object to be used with ff_*
functions
mfl_connect()
, sleeper_connect()
, fleaflicker_connect()
, espn_connect()
ff_connect(platform = "mfl", season = 2019, league_id = 54040, rate_limit = FALSE)
ff_connect(platform = "mfl", season = 2019, league_id = 54040, rate_limit = FALSE)
This function gets a tidy dataframe of draft results for the current year. Can handle MFL devy drafts or startup drafts by specifying the custom_players argument
ff_draft(conn, ...) ## S3 method for class 'espn_conn' ff_draft(conn, ...) ## S3 method for class 'flea_conn' ff_draft(conn, ...) ## S3 method for class 'mfl_conn' ff_draft(conn, custom_players = deprecated(), ...) ## S3 method for class 'sleeper_conn' ff_draft(conn, ...)
ff_draft(conn, ...) ## S3 method for class 'espn_conn' ff_draft(conn, ...) ## S3 method for class 'flea_conn' ff_draft(conn, ...) ## S3 method for class 'mfl_conn' ff_draft(conn, custom_players = deprecated(), ...) ## S3 method for class 'sleeper_conn' ff_draft(conn, ...)
conn |
a conn object created by |
... |
args for other methods |
custom_players |
A tidy dataframe of draft results
ff_draft(espn_conn)
: ESPN: returns the current year's draft/auction, including details on keepers
ff_draft(flea_conn)
: Fleaflicker: returns a table of drafts for the current year
ff_draft(mfl_conn)
: MFL: returns a table of drafts for the current year - can handle devy/startup-rookie-picks by specifying custom_players (slower!)
ff_draft(sleeper_conn)
: Sleeper: returns a dataframe of all drafts and draft selections, if available.
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect(season = 2020, league_id = 899513) ff_draft(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(season = 2020, league_id = 206154) ff_draft(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird ssb_conn <- ff_connect(platform = "mfl", league_id = 54040, season = 2020) ff_draft(ssb_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird jml_conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_draft(jml_conn) }) # end try
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect(season = 2020, league_id = 899513) ff_draft(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(season = 2020, league_id = 206154) ff_draft(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird ssb_conn <- ff_connect(platform = "mfl", league_id = 54040, season = 2020) ff_draft(ssb_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird jml_conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_draft(jml_conn) }) # end try
Returns all draft picks (current and future) that belong to a specific franchise and have not yet been converted into players (i.e. selected.)
ff_draftpicks(conn, ...) ## S3 method for class 'espn_conn' ff_draftpicks(conn, ...) ## S3 method for class 'flea_conn' ff_draftpicks(conn, franchise_id = NULL, ...) ## S3 method for class 'mfl_conn' ff_draftpicks(conn, ...) ## S3 method for class 'sleeper_conn' ff_draftpicks(conn, ...)
ff_draftpicks(conn, ...) ## S3 method for class 'espn_conn' ff_draftpicks(conn, ...) ## S3 method for class 'flea_conn' ff_draftpicks(conn, franchise_id = NULL, ...) ## S3 method for class 'mfl_conn' ff_draftpicks(conn, ...) ## S3 method for class 'sleeper_conn' ff_draftpicks(conn, ...)
conn |
the list object created by |
... |
other arguments (currently unused) |
franchise_id |
A list of franchise IDs to pull, if NULL will return all franchise IDs |
Returns a dataframe with current and future draft picks for each franchise
ff_draftpicks(espn_conn)
: ESPN: does not support future/draft pick trades - for draft results, please use ff_draft.
ff_draftpicks(flea_conn)
: Fleaflicker: retrieves current and future draft picks, potentially for a specified team.
ff_draftpicks(mfl_conn)
: MFL: returns current and future picks
ff_draftpicks(sleeper_conn)
: Sleeper: retrieves current and future draft picks
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect( season = 2018, league_id = 1178049, espn_s2 = Sys.getenv("TAN_ESPN_S2"), swid = Sys.getenv("TAN_SWID") ) ff_draftpicks(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(2020, 206154) ff_draftpicks(conn, franchise_id = 1373475) }) # end try try({ # try only shown here because sometimes CRAN checks are weird dlf_conn <- mfl_connect(2020, league_id = 37920) ff_draftpicks(conn = dlf_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird jml_conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_draftpicks(jml_conn) }) # end try
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect( season = 2018, league_id = 1178049, espn_s2 = Sys.getenv("TAN_ESPN_S2"), swid = Sys.getenv("TAN_SWID") ) ff_draftpicks(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(2020, 206154) ff_draftpicks(conn, franchise_id = 1373475) }) # end try try({ # try only shown here because sometimes CRAN checks are weird dlf_conn <- mfl_connect(2020, league_id = 37920) ff_draftpicks(conn = dlf_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird jml_conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_draftpicks(jml_conn) }) # end try
Return franchise-level data (including divisions, usernames, etc) - available data may vary slightly based on platform.
ff_franchises(conn) ## S3 method for class 'espn_conn' ff_franchises(conn) ## S3 method for class 'flea_conn' ff_franchises(conn) ## S3 method for class 'mfl_conn' ff_franchises(conn) ## S3 method for class 'sleeper_conn' ff_franchises(conn)
ff_franchises(conn) ## S3 method for class 'espn_conn' ff_franchises(conn) ## S3 method for class 'flea_conn' ff_franchises(conn) ## S3 method for class 'mfl_conn' ff_franchises(conn) ## S3 method for class 'sleeper_conn' ff_franchises(conn)
conn |
a conn object created by |
A tidy dataframe of franchises, complete with IDs
ff_franchises(espn_conn)
: ESPN: returns franchise and division information.
ff_franchises(flea_conn)
: Fleaflicker: returns franchise and division information.
ff_franchises(mfl_conn)
: MFL: returns franchise and division information.
ff_franchises(sleeper_conn)
: Sleeper: retrieves a list of franchise information, including user IDs and co-owner IDs.
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect(season = 2020, league_id = 1178049) ff_franchises(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(season = 2020, league_id = 206154) ff_franchises(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird ssb_conn <- ff_connect(platform = "mfl", league_id = 54040, season = 2020) ff_franchises(ssb_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird jml_conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_franchises(jml_conn) }) # end try
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect(season = 2020, league_id = 1178049) ff_franchises(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(season = 2020, league_id = 206154) ff_franchises(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird ssb_conn <- ff_connect(platform = "mfl", league_id = 54040, season = 2020) ff_franchises(ssb_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird jml_conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_franchises(jml_conn) }) # end try
This function returns a tidy dataframe of common league settings, including details like "1QB" or "2QB/SF", scoring, best ball, team count, IDP etc. This is potentially useful in summarising the features of multiple leagues.
ff_league(conn) ## S3 method for class 'espn_conn' ff_league(conn) ## S3 method for class 'flea_conn' ff_league(conn) ## S3 method for class 'mfl_conn' ff_league(conn) ## S3 method for class 'sleeper_conn' ff_league(conn)
ff_league(conn) ## S3 method for class 'espn_conn' ff_league(conn) ## S3 method for class 'flea_conn' ff_league(conn) ## S3 method for class 'mfl_conn' ff_league(conn) ## S3 method for class 'sleeper_conn' ff_league(conn)
conn |
the connection object created by |
A one-row summary of each league's main features.
ff_league(espn_conn)
: ESPN: returns a summary of league features.
ff_league(flea_conn)
: Flea: returns a summary of league features.
ff_league(mfl_conn)
: MFL: returns a summary of league features.
ff_league(sleeper_conn)
: Sleeper: returns a summary of league features.
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect(season = 2020, league_id = 899513) ff_league(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(2020, 206154) ff_league(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird ssb_conn <- ff_connect(platform = "mfl", league_id = 22627, season = 2021) ff_league(ssb_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird jml_conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_league(jml_conn) }) # end try
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect(season = 2020, league_id = 899513) ff_league(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(2020, 206154) ff_league(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird ssb_conn <- ff_connect(platform = "mfl", league_id = 22627, season = 2021) ff_league(ssb_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird jml_conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_league(jml_conn) }) # end try
This function returns a tidy dataframe of player scores based on league rules.
Unfortunately, Sleeper has deprecated their player stats endpoint from their supported/open API.
Please see ff_scoringhistory()
for an alternative reconstruction.
ff_playerscores(conn, ...) ## S3 method for class 'espn_conn' ff_playerscores(conn, limit = 1000, ...) ## S3 method for class 'flea_conn' ff_playerscores(conn, page_limit = NULL, ...) ## S3 method for class 'mfl_conn' ff_playerscores(conn, season, week, ...) ## S3 method for class 'sleeper_conn' ff_playerscores(conn, ...)
ff_playerscores(conn, ...) ## S3 method for class 'espn_conn' ff_playerscores(conn, limit = 1000, ...) ## S3 method for class 'flea_conn' ff_playerscores(conn, page_limit = NULL, ...) ## S3 method for class 'mfl_conn' ff_playerscores(conn, season, week, ...) ## S3 method for class 'sleeper_conn' ff_playerscores(conn, ...)
conn |
the list object created by |
... |
other arguments (currently unused) |
limit |
A numeric describing the number of players to return - default 1000 |
page_limit |
A numeric describing the number of pages to return - default NULL returns all available |
season |
the season of interest - generally only the most recent 2-3 seasons are available |
week |
a numeric vector (ie 1:17) or one of YTD (year-to-date) or AVG (average to date) |
A tibble of historical player scoring
ff_playerscores(espn_conn)
: ESPN: returns total points for season and average per game, for both current and previous season.
ff_playerscores(flea_conn)
: Fleaflicker: returns the season, season average, and standard deviation
ff_playerscores(mfl_conn)
: MFL: returns the player fantasy scores for each week (not the actual stats)
ff_playerscores(sleeper_conn)
: Sleeper: Deprecated their open API endpoint for player scores
ff_scoringhistory
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect(season = 2020, league_id = 899513) ff_playerscores(conn, limit = 5) }) # end try try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(2020, 312861) ff_playerscores(conn, page_limit = 2) }) # end try try({ # try only shown here because sometimes CRAN checks are weird sfb_conn <- mfl_connect(2020, league_id = 65443) ff_playerscores(conn = sfb_conn, season = 2019, week = "YTD") }) # end try
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect(season = 2020, league_id = 899513) ff_playerscores(conn, limit = 5) }) # end try try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(2020, 312861) ff_playerscores(conn, page_limit = 2) }) # end try try({ # try only shown here because sometimes CRAN checks are weird sfb_conn <- mfl_connect(2020, league_id = 65443) ff_playerscores(conn = sfb_conn, season = 2019, week = "YTD") }) # end try
This function returns a tidy dataframe of team rosters
ff_rosters(conn, ...) ## S3 method for class 'espn_conn' ff_rosters(conn, week = NULL, ...) ## S3 method for class 'flea_conn' ff_rosters(conn, ..., week = NULL) ## S3 method for class 'mfl_conn' ff_rosters(conn, custom_players = deprecated(), week = NULL, ...) ## S3 method for class 'sleeper_conn' ff_rosters(conn, ...)
ff_rosters(conn, ...) ## S3 method for class 'espn_conn' ff_rosters(conn, week = NULL, ...) ## S3 method for class 'flea_conn' ff_rosters(conn, ..., week = NULL) ## S3 method for class 'mfl_conn' ff_rosters(conn, custom_players = deprecated(), week = NULL, ...) ## S3 method for class 'sleeper_conn' ff_rosters(conn, ...)
conn |
a conn object created by |
... |
arguments passed to other methods (currently none) |
week |
a numeric that specifies which week to return |
custom_players |
A tidy dataframe of rosters, joined to basic player information and basic franchise information
ff_rosters(espn_conn)
: ESPN: Returns all roster data.
ff_rosters(flea_conn)
: Fleaflicker: Returns roster data (minus age as of right now)
ff_rosters(mfl_conn)
: MFL: returns roster data
ff_rosters(sleeper_conn)
: Sleeper: Returns all roster data.
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect(season = 2020, league_id = 899513) ff_league(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird joe_conn <- ff_connect(platform = "fleaflicker", league_id = 312861, season = 2020) ff_rosters(joe_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird ssb_conn <- ff_connect(platform = "mfl", league_id = 54040, season = 2020) ff_rosters(ssb_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird jml_conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_rosters(jml_conn) }) # end try
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect(season = 2020, league_id = 899513) ff_league(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird joe_conn <- ff_connect(platform = "fleaflicker", league_id = 312861, season = 2020) ff_rosters(joe_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird ssb_conn <- ff_connect(platform = "mfl", league_id = 54040, season = 2020) ff_rosters(ssb_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird jml_conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_rosters(jml_conn) }) # end try
This function returns a tidy dataframe with one row for every team for every weekly matchup
ff_schedule(conn, ...) ## S3 method for class 'espn_conn' ff_schedule(conn, ...) ## S3 method for class 'flea_conn' ff_schedule(conn, week = 1:17, ...) ## S3 method for class 'mfl_conn' ff_schedule(conn, ...) ## S3 method for class 'sleeper_conn' ff_schedule(conn, ...)
ff_schedule(conn, ...) ## S3 method for class 'espn_conn' ff_schedule(conn, ...) ## S3 method for class 'flea_conn' ff_schedule(conn, week = 1:17, ...) ## S3 method for class 'mfl_conn' ff_schedule(conn, ...) ## S3 method for class 'sleeper_conn' ff_schedule(conn, ...)
conn |
a conn object created by |
... |
for other platforms |
week |
a numeric or numeric vector specifying which weeks to pull |
A tidy dataframe with one row per game per franchise per week
ff_schedule(espn_conn)
: ESPN: returns schedule data, one row for every franchise for every week. Completed games have result data.
ff_schedule(flea_conn)
: Flea: returns schedule data, one row for every franchise for every week. Completed games have result data.
ff_schedule(mfl_conn)
: MFL: returns schedule data, one row for every franchise for every week. Completed games have result data.
ff_schedule(sleeper_conn)
: Sleeper: returns all schedule data
try({ # try only shown here because sometimes CRAN checks are weird espn_conn <- espn_connect(season = 2020, league_id = 899513) ff_schedule(espn_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(season = 2019, league_id = 206154) ff_schedule(conn, week = 2:4) }) # end try try({ # try only shown here because sometimes CRAN checks are weird ssb_conn <- ff_connect(platform = "mfl", league_id = 54040, season = 2020) ff_schedule(ssb_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird jml_conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_schedule(jml_conn) }) # end try
try({ # try only shown here because sometimes CRAN checks are weird espn_conn <- espn_connect(season = 2020, league_id = 899513) ff_schedule(espn_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(season = 2019, league_id = 206154) ff_schedule(conn, week = 2:4) }) # end try try({ # try only shown here because sometimes CRAN checks are weird ssb_conn <- ff_connect(platform = "mfl", league_id = 54040, season = 2020) ff_schedule(ssb_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird jml_conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_schedule(jml_conn) }) # end try
This function returns a dataframe with detailed scoring settings for each league - broken down by event, points, and (if available) position.
ff_scoring(conn) ## S3 method for class 'espn_conn' ff_scoring(conn) ## S3 method for class 'flea_conn' ff_scoring(conn) ## S3 method for class 'mfl_conn' ff_scoring(conn) ## S3 method for class 'sleeper_conn' ff_scoring(conn) ## S3 method for class 'template_conn' ff_scoring(conn)
ff_scoring(conn) ## S3 method for class 'espn_conn' ff_scoring(conn) ## S3 method for class 'flea_conn' ff_scoring(conn) ## S3 method for class 'mfl_conn' ff_scoring(conn) ## S3 method for class 'sleeper_conn' ff_scoring(conn) ## S3 method for class 'template_conn' ff_scoring(conn)
conn |
a conn object created by |
A tibble of league scoring rules for each position defined.
ff_scoring(espn_conn)
: ESPN: returns scoring settings in a flat table, override positions have their own scoring.
ff_scoring(flea_conn)
: Fleaflicker: returns scoring settings in a flat table, one row per position per rule.
ff_scoring(mfl_conn)
: MFL: returns scoring settings in a flat table, one row per position per rule.
ff_scoring(sleeper_conn)
: Sleeper: returns scoring settings in a flat table, one row per position per rule.
ff_scoring(template_conn)
: Template: returns MFL style scoring settings in a flat table, one row per position per rule.
http://www03.myfantasyleague.com/2020/scoring_rules#rules
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect(season = 2020, league_id = 899513) ff_scoring(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird joe_conn <- ff_connect(platform = "fleaflicker", league_id = 312861, season = 2020) ff_scoring(joe_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird ssb_conn <- ff_connect(platform = "mfl", league_id = 54040, season = 2020) ff_scoring(ssb_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird jml_conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_scoring(jml_conn) }) # end try template_ppr <- ff_template(scoring_type = "ppr") ff_scoring(template_ppr)
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect(season = 2020, league_id = 899513) ff_scoring(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird joe_conn <- ff_connect(platform = "fleaflicker", league_id = 312861, season = 2020) ff_scoring(joe_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird ssb_conn <- ff_connect(platform = "mfl", league_id = 54040, season = 2020) ff_scoring(ssb_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird jml_conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_scoring(jml_conn) }) # end try template_ppr <- ff_template(scoring_type = "ppr") ff_scoring(template_ppr)
(Experimental!) This function reads your league's ff_scoring rules and maps them to nflfastr week-level data. Not all of the scoring rules from your league may have nflfastr equivalents, but most of the common ones are available!
ff_scoringhistory(conn, season, ...) ## S3 method for class 'espn_conn' ff_scoringhistory(conn, season = 1999:nflreadr::most_recent_season(), ...) ## S3 method for class 'flea_conn' ff_scoringhistory(conn, season = 1999:nflreadr::most_recent_season(), ...) ## S3 method for class 'mfl_conn' ff_scoringhistory(conn, season = 1999:nflreadr::most_recent_season(), ...) ## S3 method for class 'sleeper_conn' ff_scoringhistory(conn, season = 1999:nflreadr::most_recent_season(), ...) ## S3 method for class 'template_conn' ff_scoringhistory(conn, season = 1999:nflreadr::most_recent_season(), ...)
ff_scoringhistory(conn, season, ...) ## S3 method for class 'espn_conn' ff_scoringhistory(conn, season = 1999:nflreadr::most_recent_season(), ...) ## S3 method for class 'flea_conn' ff_scoringhistory(conn, season = 1999:nflreadr::most_recent_season(), ...) ## S3 method for class 'mfl_conn' ff_scoringhistory(conn, season = 1999:nflreadr::most_recent_season(), ...) ## S3 method for class 'sleeper_conn' ff_scoringhistory(conn, season = 1999:nflreadr::most_recent_season(), ...) ## S3 method for class 'template_conn' ff_scoringhistory(conn, season = 1999:nflreadr::most_recent_season(), ...)
conn |
a conn object created by |
season |
season a numeric vector of seasons (earliest available year is 1999) |
... |
other arguments |
A tidy dataframe of weekly fantasy scoring data, one row per player per week
ff_scoringhistory(espn_conn)
: ESPN: returns scoring history in a flat table, one row per player per week.
ff_scoringhistory(flea_conn)
: Fleaflicker: returns scoring history in a flat table, one row per player per week.
ff_scoringhistory(mfl_conn)
: MFL: returns scoring history in a flat table, one row per player per week.
ff_scoringhistory(sleeper_conn)
: Sleeper: returns scoring history in a flat table, one row per player per week.
ff_scoringhistory(template_conn)
: template: returns scoring history in a flat table, one row per player per week.
https://www.nflfastr.com/reference/load_player_stats.html
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect(season = 2020, league_id = 899513) ff_scoringhistory(conn, season = 2020) }) # end try try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(2020, 312861) ff_scoringhistory(conn, season = 2020) }) # end try try({ # try only shown here because sometimes CRAN checks are weird ssb_conn <- ff_connect(platform = "mfl", league_id = 54040, season = 2020) ff_scoringhistory(ssb_conn, season = 2020) }) # end try try({ # try only shown here because sometimes CRAN checks are weird conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_scoringhistory(conn, season = 2020) }) # end try try({ # try only shown here because sometimes CRAN checks are weird template_conn <- ff_template(scoring_type = "sfb11", roster_type = "sfb11") ff_scoringhistory(template_conn, season = 2020) }) # end try
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect(season = 2020, league_id = 899513) ff_scoringhistory(conn, season = 2020) }) # end try try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(2020, 312861) ff_scoringhistory(conn, season = 2020) }) # end try try({ # try only shown here because sometimes CRAN checks are weird ssb_conn <- ff_connect(platform = "mfl", league_id = 54040, season = 2020) ff_scoringhistory(ssb_conn, season = 2020) }) # end try try({ # try only shown here because sometimes CRAN checks are weird conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_scoringhistory(conn, season = 2020) }) # end try try({ # try only shown here because sometimes CRAN checks are weird template_conn <- ff_template(scoring_type = "sfb11", roster_type = "sfb11") ff_scoringhistory(template_conn, season = 2020) }) # end try
This function returns a tidy dataframe of season-long fantasy team stats, including H2H wins as well as points, potential points, and all-play.
ff_standings(conn, ...) ## S3 method for class 'espn_conn' ff_standings(conn, ...) ## S3 method for class 'flea_conn' ff_standings(conn, include_allplay = TRUE, include_potentialpoints = TRUE, ...) ## S3 method for class 'mfl_conn' ff_standings(conn, ...) ## S3 method for class 'sleeper_conn' ff_standings(conn, ...)
ff_standings(conn, ...) ## S3 method for class 'espn_conn' ff_standings(conn, ...) ## S3 method for class 'flea_conn' ff_standings(conn, include_allplay = TRUE, include_potentialpoints = TRUE, ...) ## S3 method for class 'mfl_conn' ff_standings(conn, ...) ## S3 method for class 'sleeper_conn' ff_standings(conn, ...)
conn |
a conn object created by |
... |
arguments passed to other methods (currently none) |
include_allplay |
TRUE/FALSE - return all-play win pct calculation? defaults to TRUE |
include_potentialpoints |
TRUE/FALSE - return potential points calculation? defaults to TRUE. |
A tidy dataframe of standings data
ff_standings(espn_conn)
: ESPN: returns standings and points data.
ff_standings(flea_conn)
: Fleaflicker: returns H2H/points/all-play/best-ball data in a table.
ff_standings(mfl_conn)
: MFL: returns H2H/points/all-play/best-ball data in a table.
ff_standings(sleeper_conn)
: Sleeper: returns all standings and points data and manually calculates allplay results.
try({ # try only shown here because sometimes CRAN checks are weird espn_conn <- espn_connect(season = 2020, league_id = 899513) ff_standings(espn_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(season = 2020, league_id = 206154) x <- ff_standings(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird ssb_conn <- ff_connect(platform = "mfl", league_id = 54040, season = 2020) ff_standings(ssb_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird jml_conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_standings(jml_conn) }) # end try
try({ # try only shown here because sometimes CRAN checks are weird espn_conn <- espn_connect(season = 2020, league_id = 899513) ff_standings(espn_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(season = 2020, league_id = 206154) x <- ff_standings(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird ssb_conn <- ff_connect(platform = "mfl", league_id = 54040, season = 2020) ff_standings(ssb_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird jml_conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_standings(jml_conn) }) # end try
This function returns a tidy dataframe with positional lineup rules.
ff_starter_positions(conn, ...) ## S3 method for class 'espn_conn' ff_starter_positions(conn, ...) ## S3 method for class 'flea_conn' ff_starter_positions(conn, ...) ## S3 method for class 'mfl_conn' ff_starter_positions(conn, ...) ## S3 method for class 'sleeper_conn' ff_starter_positions(conn, ...) ## S3 method for class 'template_conn' ff_starter_positions(conn, ...)
ff_starter_positions(conn, ...) ## S3 method for class 'espn_conn' ff_starter_positions(conn, ...) ## S3 method for class 'flea_conn' ff_starter_positions(conn, ...) ## S3 method for class 'mfl_conn' ff_starter_positions(conn, ...) ## S3 method for class 'sleeper_conn' ff_starter_positions(conn, ...) ## S3 method for class 'template_conn' ff_starter_positions(conn, ...)
conn |
the list object created by |
... |
other arguments (currently unused) |
A tidy dataframe of positional lineup rules, one row per position with minimum and maximum starters as well as total starter calculations.
ff_starter_positions(espn_conn)
: ESPN: returns min/max starters for each main player position
ff_starter_positions(flea_conn)
: Fleaflicker: returns minimum and maximum starters for each player position.
ff_starter_positions(mfl_conn)
: MFL: returns minimum and maximum starters for each player position.
ff_starter_positions(sleeper_conn)
: Sleeper: returns minimum and maximum starters for each player position.
ff_starter_positions(template_conn)
: Template: returns minimum and maximum starters for each player position.
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect(season = 2020, league_id = 1178049) ff_starter_positions(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(season = 2020, league_id = 206154) ff_starter_positions(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird dlfidp_conn <- mfl_connect(2020, league_id = 33158) ff_starter_positions(conn = dlfidp_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird jml_conn <- sleeper_connect(league_id = "652718526494253056", season = 2021) ff_starter_positions(jml_conn) }) # end try template_conn <- ff_template(roster_type = "idp") ff_starter_positions(template_conn)
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect(season = 2020, league_id = 1178049) ff_starter_positions(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(season = 2020, league_id = 206154) ff_starter_positions(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird dlfidp_conn <- mfl_connect(2020, league_id = 33158) ff_starter_positions(conn = dlfidp_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird jml_conn <- sleeper_connect(league_id = "652718526494253056", season = 2021) ff_starter_positions(jml_conn) }) # end try template_conn <- ff_template(roster_type = "idp") ff_starter_positions(template_conn)
This function returns a tidy dataframe with one row for every starter (and bench) for every week and their scoring, if available.
ff_starters(conn, ...) ## S3 method for class 'espn_conn' ff_starters(conn, weeks = 1:17, ...) ## S3 method for class 'flea_conn' ff_starters(conn, week = 1:17, ...) ## S3 method for class 'mfl_conn' ff_starters(conn, week = 1:17, season = NULL, ...) ## S3 method for class 'sleeper_conn' ff_starters(conn, week = 1:17, ...)
ff_starters(conn, ...) ## S3 method for class 'espn_conn' ff_starters(conn, weeks = 1:17, ...) ## S3 method for class 'flea_conn' ff_starters(conn, week = 1:17, ...) ## S3 method for class 'mfl_conn' ff_starters(conn, week = 1:17, season = NULL, ...) ## S3 method for class 'sleeper_conn' ff_starters(conn, week = 1:17, ...)
conn |
the list object created by |
... |
other arguments (currently unused) |
weeks |
which weeks to calculate, a number or numeric vector |
week |
a numeric or one of YTD (year-to-date) or AVG (average to date) |
season |
the season of interest - generally only the most recent 2-3 seasons are available |
A tidy dataframe with every player for every week, including a flag for whether they were started or not
ff_starters(espn_conn)
: ESPN: returns who was started as well as what they scored.
ff_starters(flea_conn)
: Fleaflicker: returns who was started as well as what they scored.
ff_starters(mfl_conn)
: MFL: returns the player fantasy scores for each week (not the actual stats)
ff_starters(sleeper_conn)
: Sleeper: returns only "who" was started, without any scoring/stats data. Only returns season specified in initial connection object.
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect(season = 2020, league_id = 1178049) ff_starters(conn, weeks = 1:3) }) # end try try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(season = 2020, league_id = 206154) ff_starters(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird dlf_conn <- mfl_connect(2020, league_id = 37920) ff_starters(conn = dlf_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird jml_conn <- sleeper_connect(league_id = "522458773317046272", season = 2020) ff_starters(jml_conn, week = 3) }) # end try
try({ # try only shown here because sometimes CRAN checks are weird conn <- espn_connect(season = 2020, league_id = 1178049) ff_starters(conn, weeks = 1:3) }) # end try try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(season = 2020, league_id = 206154) ff_starters(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird dlf_conn <- mfl_connect(2020, league_id = 37920) ff_starters(conn = dlf_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird jml_conn <- sleeper_connect(league_id = "522458773317046272", season = 2020) ff_starters(jml_conn, week = 3) }) # end try
conn
objectsThis function creates a connection to a few league templates, and can be used instead of a real conn object in the following functions: ff_scoring()
, ff_scoringhistory()
, ff_starterpositions()
.
ff_template( scoring_type = c("ppr", "half_ppr", "zero_ppr", "sfb11"), roster_type = c("1qb", "superflex", "sfb11", "idp") )
ff_template( scoring_type = c("ppr", "half_ppr", "zero_ppr", "sfb11"), roster_type = c("1qb", "superflex", "sfb11", "idp") )
scoring_type |
One of c("default", "ppr", "half_ppr", "zero_ppr", "te_prem", "sfb11") |
roster_type |
One of c("1qb", "superflex","sfb11", "idp") |
Scoring types defined here are:
ppr
: 6 pt passing/rushing/receiving touchdowns, 0.1 for rushing/receiving yards, 1 point per reception, -2 for fumbles/interceptions
half_ppr
: same as ppr
but with 0.5 points per reception
zero_ppr
: same as ppr
but with 0 points per reception
te_prem
: same as ppr
but TEs get 1.5 points per reception
sfb11
: SFB11 scoring as defined by https://scottfishbowl.com
Roster settings defined here are:
1qb
: Starts 1 QB, 2 RB, 3 WR, 1 TE, 2 FLEX
superflex
: Starts 1 QB, 2 RB, 3 WR, 1 TE, 2 FLEX, 1 SUPERFLEX
sfb11
: Starts 1 QB, 2 RB, 3 WR, 1 TE, 3 FLEX, 1 SUPERFLEX (flex positions can also start a kicker)
idp
: Starts same as 1QB but also starts 3 DL, 3 LB, 3 DB, and two IDP FLEX
a connection object that can be used with ff_scoring()
, ff_scoringhistory()
, and ff_starterpositions()
This function returns a tidy dataframe of transactions - generally one row per player per transaction per team. Each trade is represented twice, once per each team.
ff_transactions(conn, ...) ## S3 method for class 'espn_conn' ff_transactions(conn, limit = 1000, ...) ## S3 method for class 'flea_conn' ff_transactions(conn, franchise_id = NULL, ...) ## S3 method for class 'mfl_conn' ff_transactions(conn, transaction_type = "*", ...) ## S3 method for class 'sleeper_conn' ff_transactions(conn, week = 1:17, ...)
ff_transactions(conn, ...) ## S3 method for class 'espn_conn' ff_transactions(conn, limit = 1000, ...) ## S3 method for class 'flea_conn' ff_transactions(conn, franchise_id = NULL, ...) ## S3 method for class 'mfl_conn' ff_transactions(conn, transaction_type = "*", ...) ## S3 method for class 'sleeper_conn' ff_transactions(conn, week = 1:17, ...)
conn |
the list object created by |
... |
additional args for other methods |
limit |
number of most recent transactions to return |
franchise_id |
fleaflicker returns transactions grouped by franchise id, pass a list here to filter |
transaction_type |
parameter to return transactions of the specified type. Types are: |
week |
A week filter for transactions - 1 returns all offseason transactions. Default 1:17 returns all transactions. |
A tidy dataframe of transaction data
ff_transactions(espn_conn)
: ESPN: returns adds, drops, and trades. Requires private/auth-cookie.
ff_transactions(flea_conn)
: Fleaflicker: returns all transactions, including free agents, waivers, and trades.
ff_transactions(mfl_conn)
: MFL: returns all transactions, including auction, free agents, IR, TS, waivers, and trades.
ff_transactions(sleeper_conn)
: Sleeper: returns all transactions, including free agents, waivers, and trades.
## Not run: # Marked as don't run because this endpoint requires private authentication conn <- espn_connect( season = 2020, league_id = 1178049, swid = Sys.getenv("TAN_SWID"), espn_s2 = Sys.getenv("TAN_ESPN_S2") ) ff_transactions(conn) ## End(Not run) try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(season = 2020, league_id = 312861) ff_transactions(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird dlf_conn <- mfl_connect(2019, league_id = 37920) ff_transactions(dlf_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird jml_conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_transactions(jml_conn, week = 1:2) }) # end try
## Not run: # Marked as don't run because this endpoint requires private authentication conn <- espn_connect( season = 2020, league_id = 1178049, swid = Sys.getenv("TAN_SWID"), espn_s2 = Sys.getenv("TAN_ESPN_S2") ) ff_transactions(conn) ## End(Not run) try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(season = 2020, league_id = 312861) ff_transactions(conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird dlf_conn <- mfl_connect(2019, league_id = 37920) ff_transactions(dlf_conn) }) # end try try({ # try only shown here because sometimes CRAN checks are weird jml_conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_transactions(jml_conn, week = 1:2) }) # end try
This function returns a tidy dataframe with one row for every league a user is in. This requries authentication cookies for MFL usage.
ff_userleagues(conn, ...) ## S3 method for class 'espn_conn' ff_userleagues(conn = NULL, ...) ## S3 method for class 'flea_conn' ff_userleagues(conn = NULL, user_email = NULL, season = NULL, ...) ## S3 method for class 'mfl_conn' ff_userleagues(conn, season = NULL, ...) ## S3 method for class 'sleeper_conn' ff_userleagues(conn = NULL, user_name = NULL, season = NULL, ...)
ff_userleagues(conn, ...) ## S3 method for class 'espn_conn' ff_userleagues(conn = NULL, ...) ## S3 method for class 'flea_conn' ff_userleagues(conn = NULL, user_email = NULL, season = NULL, ...) ## S3 method for class 'mfl_conn' ff_userleagues(conn, season = NULL, ...) ## S3 method for class 'sleeper_conn' ff_userleagues(conn = NULL, user_name = NULL, season = NULL, ...)
conn |
a connection object created by |
... |
arguments that may be passed to other methods (for method consistency) |
user_email |
the username to look up - defaults to user created in conn if available |
season |
the season to look up leagues for |
user_name |
the username to look up - defaults to user created in conn if available |
A tidy dataframe with one row for every league a user is in
ff_userleagues(espn_conn)
: ESPN: does not support a lookup of user leagues by email or user ID at this time.
ff_userleagues(flea_conn)
: flea: returns a listing of leagues for a given user_email
ff_userleagues(mfl_conn)
: MFL: With username/password, it will return a list of user leagues.
ff_userleagues(sleeper_conn)
: Sleeper: returns a listing of leagues for a given user_id or user_name
fleaflicker_userleagues()
to call this function for flea leagues without first creating a connection object.
sleeper_userleagues()
to call this function for Sleeper leagues without first creating a connection object.
This function creates a connection object which stores parameters and a user ID if available.
fleaflicker_connect( season = NULL, league_id = NULL, user_email = NULL, user_agent = NULL, rate_limit = TRUE, rate_limit_number = NULL, rate_limit_seconds = NULL, ... )
fleaflicker_connect( season = NULL, league_id = NULL, user_email = NULL, user_agent = NULL, rate_limit = TRUE, rate_limit_number = NULL, rate_limit_seconds = NULL, ... )
season |
Season to access on Fleaflicker - if missing, will guess based on system date (current year if March or later, otherwise previous year) |
league_id |
League ID |
user_email |
Optional - attempts to get user's user ID by email |
user_agent |
User agent to self-identify (optional) |
rate_limit |
TRUE by default - turn off rate limiting with FALSE |
rate_limit_number |
number of calls per |
rate_limit_seconds |
number of seconds as denominator for rate_limit |
... |
other arguments (for other methods, for R compat) |
a list that stores Fleaflicker connection objects
The endpoint names and HTTP parameters (i.e. argument names) are CASE SENSITIVE and should be passed in exactly as displayed on the Fleaflicker API reference page.
fleaflicker_getendpoint(endpoint, ...)
fleaflicker_getendpoint(endpoint, ...)
endpoint |
a string defining which endpoint to return from the API |
... |
Arguments which will be passed as "argumentname = argument" in an HTTP query parameter |
Check out the vignette for more details and example usage.
A list object containing the query, response, and parsed content.
https://www.fleaflicker.com/api-docs/index.html
vignette("fleaflicker_getendpoint")
A cached table of Fleaflicker NFL players. Will store in memory for each session! (via memoise in zzz.R)
fleaflicker_players(conn, page_limit = NULL)
fleaflicker_players(conn, page_limit = NULL)
conn |
a conn object created by |
page_limit |
A number limiting the number of players to return, or NULL (default) returns all |
a dataframe containing all ~7000+ players in the Fleaflicker database
try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(2020, 312861) player_list <- fleaflicker_players(conn, page_limit = 2) }) # end try
try({ # try only shown here because sometimes CRAN checks are weird conn <- fleaflicker_connect(2020, 312861) player_list <- fleaflicker_players(conn, page_limit = 2) }) # end try
This function returns the leagues that a specific user is in. This variant can be used without first creating a connection object.
fleaflicker_userleagues(user_email, season = NULL)
fleaflicker_userleagues(user_email, season = NULL)
user_email |
the username to look up |
season |
the season to return leagues from - defaults to current year based on heuristics |
a dataframe of leagues for the specified user
This function creates a connection object which stores parameters and gets a login-cookie if available
mfl_connect( season = NULL, league_id = NULL, APIKEY = NULL, user_name = NULL, password = NULL, user_agent = NULL, rate_limit = TRUE, rate_limit_number = NULL, rate_limit_seconds = NULL, ... )
mfl_connect( season = NULL, league_id = NULL, APIKEY = NULL, user_name = NULL, password = NULL, user_agent = NULL, rate_limit = TRUE, rate_limit_number = NULL, rate_limit_seconds = NULL, ... )
season |
Season to access on MFL - if missing, will guess based on system date (current year if March or later, otherwise previous year) |
league_id |
league_id Numeric ID parameter for each league, typically found in the URL |
APIKEY |
APIKEY - optional - allows access to private leagues. Key is unique for each league and accessible from Developer's API page (currently assuming one league at a time) |
user_name |
MFL user_name - optional - when supplied in conjunction with a password, will attempt to retrieve authentication token |
password |
MFL password - optional - when supplied in conjunction with user_name, will attempt to retrieve authentication token |
user_agent |
A string representing the user agent to be used to identify calls - may find improved rate_limits if verified token |
rate_limit |
TRUE by default, pass FALSE to turn off rate limiting |
rate_limit_number |
number of calls per |
rate_limit_seconds |
number of seconds as denominator for rate_limit |
... |
silently swallows up unused arguments |
a connection object to be used with ff_*
functions
mfl_connect(season = 2020, league_id = 54040) mfl_connect(season = 2019, league_id = 54040, rate_limit = FALSE)
mfl_connect(season = 2020, league_id = 54040) mfl_connect(season = 2019, league_id = 54040, rate_limit = FALSE)
Create a GET request to any MFL export endpoint.
mfl_getendpoint(conn, endpoint, ...)
mfl_getendpoint(conn, endpoint, ...)
conn |
the list object created by |
endpoint |
a string defining which endpoint to return from the API |
... |
Arguments which will be passed as "argumentname = argument" in an HTTP query parameter |
This function will read the connection object and automatically pass in the rate-limiting, league ID (L), authentication cookie, and/or API key (APIKEY) if configured in the connection object.
The endpoint names and HTTP parameters (i.e. argument names) are CASE SENSITIVE and should be passed in exactly as displayed on the MFL API reference page.
Check out the vignette for more details and example usage.
A list object containing the query, response, and parsed content.
https://api.myfantasyleague.com/2020/api_info?STATE=details
vignette("mfl_getendpoint")
A cached table of MFL players. Will store in memory for each session! (via memoise in zzz.R)
mfl_players(conn = NULL)
mfl_players(conn = NULL)
conn |
optionally, pass in a conn object generated by ff_connect to receive league-specific custom players |
a dataframe containing all ~2000+ players in the MFL database
try({ # try only shown here because sometimes CRAN checks are weird player_list <- mfl_players() dplyr::sample_n(player_list, 5) }) # end try
try({ # try only shown here because sometimes CRAN checks are weird player_list <- mfl_players() dplyr::sample_n(player_list, 5) }) # end try
Deprecated in favour of nflreadr::load_rosters()
nflfastr_rosters(...)
nflfastr_rosters(...)
... |
deprecated |
A small helper dataframe for connecting nflfastr to specific fantasy platform rules.
nflfastr_stat_mapping
nflfastr_stat_mapping
A data frame with ~85 rows and 3 variables:
the column name of the statistic in the nflfastr_weekly dataset
specific platform that this mapping applies to
name of the statistic for that platform
Deprecated in favour of nflreadr::load_player_stats()
nflfastr_weekly(...)
nflfastr_weekly(...)
... |
deprecated |
This function creates a connection object which stores parameters and a user ID if available.
sleeper_connect( season = NULL, league_id = NULL, user_name = NULL, user_agent = NULL, rate_limit = TRUE, rate_limit_number = NULL, rate_limit_seconds = NULL, ... )
sleeper_connect( season = NULL, league_id = NULL, user_name = NULL, user_agent = NULL, rate_limit = TRUE, rate_limit_number = NULL, rate_limit_seconds = NULL, ... )
season |
Season to access on Sleeper - if missing, will guess based on system date (current year if March or later, otherwise previous year) |
league_id |
League ID (currently assuming one league at a time) |
user_name |
Sleeper user_name - optional - attempts to get user's user ID |
user_agent |
User agent to self-identify (optional) |
rate_limit |
TRUE by default - turn off rate limiting with FALSE |
rate_limit_number |
number of calls per |
rate_limit_seconds |
number of seconds as denominator for rate_limit |
... |
other arguments (for other methods) |
a list that stores Sleeper connection objects
This function retrieves drafts by sleeper's draft ID. This better supports mock drafts.
sleeper_draft(draft_id)
sleeper_draft(draft_id)
draft_id |
draft ID as found in URL e.g. "https://sleeper.com/draft/nfl/draft_id" |
draft dataframe
The endpoint names and HTTP parameters (i.e. argument names) are CASE SENSITIVE and should be passed in exactly as displayed on the Sleeper API reference page.
sleeper_getendpoint(endpoint, ...)
sleeper_getendpoint(endpoint, ...)
endpoint |
a string defining which endpoint to return from the API |
... |
Arguments which will be passed as "argumentname = argument" in an HTTP query parameter |
Check out the vignette for more details and example usage.
A list object containing the query, response, and parsed content.
vignette("sleeper_getendpoint")
A cached table of Sleeper NFL players. Will store in memory for each session! (via memoise in zzz.R)
sleeper_players()
sleeper_players()
a dataframe containing all ~7000+ players in the Sleeper database
try({ # try only shown here because sometimes CRAN checks are weird x <- sleeper_players() dplyr::sample_n(x, 5) }) # end try
try({ # try only shown here because sometimes CRAN checks are weird x <- sleeper_players() dplyr::sample_n(x, 5) }) # end try
This function returns the leagues that a specific user is in. This variant can be used without first creating a connection object.
sleeper_userleagues(user_name, season = NULL)
sleeper_userleagues(user_name, season = NULL)
user_name |
the username to look up |
season |
the season to return leagues from - defaults to current year based on heuristics |
a dataframe of leagues for the specified user