### Get Starters with Sleeper Connection and Specific Week Source: https://ffscrapr.ffverse.com/reference/ff_starters.html Fetches starter data for a specific week from a Sleeper league. This example demonstrates how to specify the week parameter when using a Sleeper connection. ```r try({ jml_conn <- sleeper_connect(league_id = "522458773317046272", season = 2020) ff_starters(jml_conn, week = 3) }) ``` -------------------------------- ### Get ESPN Starters Source: https://ffscrapr.ffverse.com/reference/ff_starters.html Retrieves starting lineups and scores for a specified range of weeks from an ESPN league connection. Requires an active ESPN connection object. ```r # \donttest{ try({ conn <- espn_connect(season = 2020, league_id = 1178049) ff_starters(conn, weeks = 1:3) }) # end try ``` -------------------------------- ### Install Development Dependencies Source: https://ffscrapr.ffverse.com/CONTRIBUTING.html Installs all necessary development dependencies for the package. ```r devtools::install_dev_deps() ``` -------------------------------- ### Get Fleaflicker Starters Source: https://ffscrapr.ffverse.com/reference/ff_starters.html Retrieves starting lineups and scores for a Fleaflicker league connection. By default, it fetches data for all weeks in the season. Requires an active Fleaflicker connection object. ```r # \donttest{ try({ conn <- fleaflicker_connect(season = 2020, league_id = 206154) ff_starters(conn) }) # end try ``` -------------------------------- ### Install ffscrapr (Development Version) Source: https://ffscrapr.ffverse.com/index.html Installs the development version of the ffscrapr package from r-universe or GitHub. pak and remotes are recommended installation tools. ```r install.packages("ffscrapr", repos = c("https://ffverse.r-universe.dev", getOption("repos"))) ``` ```r pak::pak("ffverse/ffscrapr") ``` ```r remotes::install_github("ffverse/ffscrapr") ``` -------------------------------- ### ff_starter_positions() Source: https://ffscrapr.ffverse.com/reference/index.html Retrieve starting lineup settings. This is a primary function designed to work for all platforms. ```APIDOC ## ff_starter_positions() ### Description Get Starting Lineup Settings. This is a primary function designed to work for all platforms. ### Method Not Applicable (Function Call) ### Parameters (Specific parameters not detailed in the source text) ### Request Example (Not Applicable) ### Response (Not Applicable) ``` -------------------------------- ### ff_starters() Source: https://ffscrapr.ffverse.com/reference/index.html Retrieve starting lineups for a fantasy football league. This is a primary function designed to work for all platforms. ```APIDOC ## ff_starters() ### Description Get Starting Lineups. This is a primary function designed to work for all platforms. ### Method Not Applicable (Function Call) ### Parameters (Specific parameters not detailed in the source text) ### Request Example (Not Applicable) ### Response (Not Applicable) ``` -------------------------------- ### Install ffscrapr Development Version (r-universe) Source: https://ffscrapr.ffverse.com/dev Installs the development version of the ffscrapr package from the ffverse r-universe repository. ```r install.packages("ffscrapr", repos = "https://ffverse.r-universe.dev") ``` -------------------------------- ### Get MFL Search Results Source: https://ffscrapr.ffverse.com/articles/mfl_getendpoint.html Retrieves search results from the MFL API. This is a basic example showing how to connect to the MFL API and fetch initial search data. ```r head(search_results) #> # A tibble: 6 × 4 #> id name year homeURL #> #> 1 13411 #SFBX Conference 12 2020 https//www43.myfantasyleague.com/2020/home/13… #> 2 16428 #SFBX Conference 6 2020 https//www43.myfantasyleague.com/2020/home/16… #> 3 17910 #SFBX Conference 11 2020 https//www43.myfantasyleague.com/2020/home/17… #> 4 26453 #SFBX Conference 8 2020 https//www43.myfantasyleague.com/2020/home/26… #> 5 27495 #SFBX Conference 2 2020 https//www43.myfantasyleague.com/2020/home/27… #> 6 31492 #SFBX Conference 14 2020 https//www43.myfantasyleague.com/2020/home/31… ``` -------------------------------- ### Install ffscrapr Development Version (remotes) Source: https://ffscrapr.ffverse.com/dev Installs the development version of the ffscrapr package using the remotes package. ```r remotes::install_github("ffverse/ffscrapr") ``` -------------------------------- ### Install ffscrapr Development Version (pak) Source: https://ffscrapr.ffverse.com/dev Installs the development version of the ffscrapr package using the pak package manager. ```r pak::pak("ffverse/ffscrapr") ``` -------------------------------- ### Install ffscrapr Stable Version Source: https://ffscrapr.ffverse.com/dev Installs the latest stable version of the ffscrapr package from CRAN. ```r install.packages("ffscrapr") ``` -------------------------------- ### Get MFL League Summary Source: https://ffscrapr.ffverse.com/reference/ff_league.html Connects to an MFL league and retrieves a summary of its features. Use `ff_connect` with platform set to 'mfl'. ```r # \donttest{ try({ ssb_conn <- ff_connect(platform = "mfl", league_id = 22627, season = 2021) ff_league(ssb_conn) }) # } ``` -------------------------------- ### Get Sleeper League Summary Source: https://ffscrapr.ffverse.com/reference/ff_league.html Connects to a Sleeper league and retrieves a summary of its features. Ensure the platform is specified as 'sleeper' in `ff_connect`. ```r # \donttest{ try({ jml_conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_league(jml_conn) }) # } ``` -------------------------------- ### Get Starter Positions for a Specific League Source: https://ffscrapr.ffverse.com/reference/ff_starter_positions.html Retrieves the starter position requirements for a given fantasy football league and season. Requires establishing a connection to the league first. ```r jml_conn <- sleeper_connect(league_id = "652718526494253056", season = 2021) ff_starter_positions(jml_conn) ``` -------------------------------- ### Get Starters with MFL Connection Source: https://ffscrapr.ffverse.com/reference/ff_starters.html Retrieves starter data for a specific league and season using an MFL connection. Ensure the connection object is properly established before calling the function. ```r try({ dlf_conn <- mfl_connect(2020, league_id = 37920) ff_starters(conn = dlf_conn) }) ``` -------------------------------- ### Get League Settings Source: https://ffscrapr.ffverse.com/index.html Retrieves a summary of league settings using ff_league() after establishing a connection. The output is a tibble containing detailed league information. ```r # Get a summary of league settings ff_league(ssb) %>% str() #> tibble [1 × 17] (S3: tbl_df/tbl/data.frame) #> $ league_id : chr "54040" #> $ league_name : chr "The Super Smash Bros Dynasty League" #> $ season : int 2020 #> $ league_type : chr NA #> $ franchise_count : num 14 #> $ qb_type : chr "1QB" #> $ idp : logi FALSE #> $ scoring_flags : chr "0.5_ppr, TEPrem, PP1D" #> $ best_ball : logi FALSE #> $ salary_cap : logi FALSE #> $ player_copies : num 1 #> $ years_active : chr "2018-2021" #> $ qb_count : chr "1" #> $ roster_size : num 33 #> $ league_depth : num 462 #> $ draft_type : chr " email draft" #> $ draft_player_pool: chr "Both" ``` -------------------------------- ### Load Fleaflicker and Data Manipulation Packages Source: https://ffscrapr.ffverse.com/articles/fleaflicker_basics.html Load the necessary R packages for interacting with Fleaflicker and performing data manipulation. Ensure these packages are installed before running. ```R library(ffscrapr) library(dplyr) library(tidyr) ``` -------------------------------- ### Get Fleaflicker Starter Positions Source: https://ffscrapr.ffverse.com/reference/ff_starter_positions.html Retrieves the minimum and maximum starters for each player position from a Fleaflicker connection. This function requires an active Fleaflicker connection established via `fleaflicker_connect()`. ```R conn <- fleaflicker_connect(season = 2020, league_id = 206154) ff_starter_positions(conn) ``` -------------------------------- ### Connect to MFL League with Season and League ID Source: https://ffscrapr.ffverse.com/reference/mfl_connect.html Establishes a connection to a specific MFL league for a given season. This example demonstrates basic usage with required parameters. ```R # \donttest{ mfl_connect(season = 2020, league_id = 54040) #> #> #> #> List of 5 #> $ platform : chr "MFL" #> $ season : num 2020 #> $ league_id : chr "54040" #> $ APIKEY : NULL #> $ auth_cookie: NULL #> - attr(*, "class")= chr "mfl_conn" # } ``` -------------------------------- ### Get ESPN Standings Source: https://ffscrapr.ffverse.com/reference/ff_standings.html Connects to an ESPN league and retrieves standings data. Use this when working with ESPN fantasy leagues. ```r # \donttest{ try({ espn_conn <- espn_connect(season = 2020, league_id = 899513) ff_standings(espn_conn) }) # end try #> # A tibble: 10 × 12 #> franchise_id franchise_name league_rank h2h_wins h2h_losses h2h_ties #> #> 1 1 "The Early GGod" 7 3 9 0 #> 2 2 "Coom Dumpster" 3 7 5 0 #> 3 3 "PAKI STANS" 6 4 8 0 #> 4 4 "I'm Also Sad " 5 7 5 0 #> 5 5 "The Juggernaut" 1 9 3 0 #> 6 6 "OBJ's Personal Porta … 4 8 4 0 #> 7 7 "Tony El Tigre" 9 5 7 0 #> 8 8 "Big Coomers" 8 6 6 0 #> 9 9 "RAFI CUNADO" 2 7 5 0 #> 10 10 "Austin 🐐Drew Lock🐐" 10 4 8 0 #> # ℹ 6 more variables: h2h_winpct , points_for , points_against , #> # allplay_wins , allplay_losses , allplay_winpct # } ``` -------------------------------- ### MFL: Get League Rosters Source: https://ffscrapr.ffverse.com/reference/ff_rosters.html Retrieves roster data for an MFL league connection. Custom player data is now returned by default. ```r # \donttest{ try({ ssb_conn <- ff_connect(platform = "mfl", league_id = 54040, season = 2020) ff_rosters(ssb_conn) }) # end try ``` -------------------------------- ### Connect to ESPN API and Get Draft Details Source: https://ffscrapr.ffverse.com/articles/espn_getendpoint.html Establishes a connection to the ESPN API for a specific league and season, then retrieves draft details using the 'mDraftDetail' view. ```r conn <- espn_connect(season = 2020, league_id = 899513) draft_details <- espn_getendpoint(conn, view = "mDraftDetail") draft_details #> #> QUERY: #> List of 8 #> $ draftDetail :List of 4 #> $ gameId : int 1 #> $ id : int 899513 #> $ scoringPeriodId: int 18 #> $ seasonId : int 2020 #> $ segmentId : int 0 #> $ settings :List of 1 #> $ status :List of 21 ``` -------------------------------- ### Get Flea Flicker League Summary Source: https://ffscrapr.ffverse.com/reference/ff_league.html Connects to a Flea Flicker league and retrieves a summary of its features. Requires a Flea Flicker connection object. ```r # \donttest{ try({ conn <- fleaflicker_connect(2020, 206154) ff_league(conn) }) # } ``` -------------------------------- ### Get ESPN League Scoring Settings Source: https://ffscrapr.ffverse.com/reference/ff_scoring.html Retrieves scoring settings for an ESPN league. Use this to understand the point values for various stats in your league. ```r # \donttest{ try({ conn <- espn_connect(season = 2020, league_id = 899513) ff_scoring(conn) }) # } ``` -------------------------------- ### Get League Rosters Source: https://ffscrapr.ffverse.com/dev Retrieves the rosters for a connected fantasy football league using the ff_rosters function. The output is a tibble containing player and franchise information. ```r ff_rosters(ssb) #> # A tibble: 442 x 11 #> franchise_id franchise_name player_id player_name pos team age #> #> 1 0001 Team Pikachu 13189 Engram, Evan TE NYG 27.7 #> 2 0001 Team Pikachu 11680 Landry, Jarvis WR CLE 29.5 #> 3 0001 Team Pikachu 13645 Smith, Tre'Quan WR NOS 26.3 #> 4 0001 Team Pikachu 12110 Brate, Cameron TE TBB 30.9 #> 5 0001 Team Pikachu 13168 Reynolds, Josh WR LAR 27.2 #> # ... with 437 more rows, and 4 more variables: roster_status , #> # drafted , draft_year , draft_round ``` -------------------------------- ### ff_starter_positions Source: https://ffscrapr.ffverse.com/reference/ff_starter_positions.html Returns a tidy dataframe of positional lineup rules, detailing minimum and maximum starters, and total starter calculations for different fantasy football platforms. ```APIDOC ## ff_starter_positions ### Description Returns a tidy dataframe of positional lineup rules, one row per position with minimum and maximum starters as well as total starter calculations. ### Usage ``` 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, ...) ``` ### Arguments * `conn` (list): The list object created by `ff_connect()`. * `...` (any): Other arguments (currently unused). ### Value A tidy dataframe of positional lineup rules, one row per position with minimum and maximum starters as well as total starter calculations. ### Methods (by class) * `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. ### Examples ```R # ESPN Example conn <- espn_connect(season = 2020, league_id = 1178049) ff_starter_positions(conn) # Fleaflicker Example conn <- fleaflicker_connect(season = 2020, league_id = 206154) ff_starter_positions(conn) # MFL Example dlfidp_conn <- mfl_connect(2020, league_id = 33158) ff_starter_positions(conn = dlfidp_conn) ``` ``` -------------------------------- ### Get MFL League Scoring Settings Source: https://ffscrapr.ffverse.com/reference/ff_scoring.html Retrieves scoring settings for an MFL league. The output includes point values, ranges, event types, and descriptions for each scoring rule. ```r # \donttest{ try({ ssb_conn <- ff_connect(platform = "mfl", league_id = 54040, season = 2020) ff_scoring(ssb_conn) }) # } ``` -------------------------------- ### Make Custom Sleeper API Request Source: https://ffscrapr.ffverse.com/articles/sleeper_getendpoint.html Execute a custom GET request to the Sleeper API using `sleeper_getendpoint`. This example fetches trending players for the NFL, specifying a lookback period and a limit. ```R response_trending <- sleeper_getendpoint(query,lookback_hours = 48, limit = 10) ``` -------------------------------- ### Get Scoring History from Template Connection Source: https://ffscrapr.ffverse.com/reference/ff_scoringhistory.html Fetches scoring history using a template connection, which is useful for standardized scoring types and roster configurations. This example uses 'sfb11' for both scoring and roster types. ```r template_conn <- ff_template(scoring_type = "sfb11", roster_type = "sfb11") ff_scoringhistory(template_conn, season = 2020) ``` -------------------------------- ### Calculate Optimal Starters for a Week Source: https://ffscrapr.ffverse.com/reference/espn_potentialpoints.html Connect to ESPN and calculate the optimal lineup for a specific week. This is useful for understanding lineup strategy and potential player performance. ```r conn <- espn_connect(season = 2021, league_id = 950665) espn_potentialpoints(conn, weeks = 1) ``` -------------------------------- ### ff_starters Source: https://ffscrapr.ffverse.com/reference/ff_starters.html Returns a tidy dataframe with one row for every starter (and bench) for every week and their scoring, if available. This function has methods for different connection types like espn, fleaflicker, mfl, and sleeper. ```APIDOC ## ff_starters ### Description Returns a tidy dataframe with one row for every starter (and bench) for every week and their scoring, if available. This function is designed to work with various fantasy football connection objects. ### Usage ```R 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, ...) ``` ### Arguments * **conn** (object) - The list object created by `ff_connect()`. * **...** - Other arguments (currently unused). * **weeks** (numeric vector) - Which weeks to calculate, a number or numeric vector. * **week** (numeric or character) - A numeric or one of 'YTD' (year-to-date) or 'AVG' (average to date). * **season** (numeric or character) - The season of interest - generally only the most recent 2-3 seasons are available. ### Value A tidy dataframe with every player for every week, including a flag for whether they were started or not. ### Methods (by class) * `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. ### Examples ```R # Example for espn_conn conn_espn <- espn_connect(season = 2020, league_id = 1178049) ff_starters(conn_espn, weeks = 1:3) # Example for fleaflicker_conn conn_flea <- fleaflicker_connect(season = 2020, league_id = 206154) ff_starters(conn_flea) ``` ``` -------------------------------- ### Clean Player Names with Last, First and Name Database Source: https://ffscrapr.ffverse.com/reference/dp_clean_names.html Shows how to convert names from 'Last, First' format to 'First Last' and utilize the internal name database for common substitutions. This example uses `convert_lastfirst = TRUE` and `use_name_database = TRUE`. ```R dp_cleannames(c("Trubisky, Mitch", "Atwell, Chatarius", "Elliott, Zeke", "Elijah Moore"), convert_lastfirst = TRUE, use_name_database = TRUE ) #> [1] "Mitchell Trubisky" "Tutu Atwell" "Ezekiel Elliott" #> [4] "Elijah Moore" # } ``` -------------------------------- ### Storing ESPN Credentials as Environment Variables Source: https://ffscrapr.ffverse.com/articles/espn_authentication.html Add your ESPN_S2 and SWID values to your .Renviron file. These values are sensitive and should be kept secure. ```R TAN_ESPN_S2="AECt%2F12312Dwd5ktQSzfuG" TAN_SWID="{1E6CC139-}" ``` -------------------------------- ### Get Starter Positions for a Template League (IDP) Source: https://ffscrapr.ffverse.com/reference/ff_starter_positions.html Retrieves the starter position requirements for a template league configured for Individual Defensive Players (IDP). This is useful for understanding default settings. ```r template_conn <- ff_template(roster_type = "idp") ff_starter_positions(template_conn) ``` -------------------------------- ### Make a Custom MFL API GET Request Source: https://ffscrapr.ffverse.com/articles/mfl_getendpoint.html Use mfl_getendpoint to make a custom GET request to an MFL API endpoint. Ensure endpoint and parameter names match MFL's case-sensitive requirements. ```R sfb_search <- mfl_getendpoint(conn,endpoint = "leagueSearch", SEARCH = "sfbx conference") #> Using request.R from "ffscrapr" ``` -------------------------------- ### Establish ESPN League Connection Source: https://ffscrapr.ffverse.com/reference/espn_connect.html Example of how to use the espn_connect function to create a connection object for a specific season and league ID. It utilizes environment variables for authentication tokens. ```R # \donttest{ conn <- espn_connect( season = 2018, league_id = 1178049, espn_s2 = Sys.getenv("TAN_ESPN_S2"), swid = Sys.getenv("TAN_SWID") ) # } ``` -------------------------------- ### fleaflicker_getendpoint() Source: https://ffscrapr.ffverse.com/reference/index.html GET any Fleaflicker endpoint. This function is optimized for the Fleaflicker platform. ```APIDOC ## fleaflicker_getendpoint() ### Description GET any Fleaflicker endpoint. This function is optimized for the Fleaflicker platform. ### Method Not Applicable (Function Call) ### Parameters (Specific parameters not detailed in the source text) ### Request Example (Not Applicable) ### Response (Not Applicable) ``` -------------------------------- ### sleeper_getendpoint() Source: https://ffscrapr.ffverse.com/reference/index.html GET any Sleeper endpoint. This function is optimized for the Sleeper platform. ```APIDOC ## sleeper_getendpoint() ### Description GET any Sleeper endpoint. This function is optimized for the Sleeper platform. ### Method Not Applicable (Function Call) ### Parameters (Specific parameters not detailed in the source text) ### Request Example (Not Applicable) ### Response (Not Applicable) ``` -------------------------------- ### Connect to a Fantasy League and Get Settings Source: https://ffscrapr.ffverse.com/dev Establishes a connection to a fantasy football league using ff_connect and retrieves league settings using ff_league. The connection object stores platform, league ID, and season parameters. ```r library(ffscrapr) ssb <- ff_connect(platform = "mfl", league_id = "54040", season = 2020) # Get a summary of league settings ff_league(ssb) %>% str() #> tibble [1 x 17] (S3: tbl_df/tbl/data.frame) #> $ league_id : chr "54040" #> $ league_name : chr "The Super Smash Bros Dynasty League" #> $ season : int 2020 #> $ league_type : chr NA #> $ franchise_count : num 14 #> $ qb_type : chr "1QB" #> $ idp : logi FALSE #> $ scoring_flags : chr "0.5_ppr, TEPrem, PP1D" #> $ best_ball : logi FALSE #> $ salary_cap : logi FALSE #> $ player_copies : num 1 #> $ years_active : chr "2018-2021" #> $ qb_count : chr "1" #> $ roster_size : num 33 #> $ league_depth : num 462 #> $ draft_type : chr "email draft" #> $ draft_player_pool: chr "Both" ``` -------------------------------- ### mfl_getendpoint() Source: https://ffscrapr.ffverse.com/reference/index.html GET any MFL endpoint. This function is optimized for the MFL platform. ```APIDOC ## mfl_getendpoint() ### Description GET any MFL endpoint. This function is optimized for the MFL platform. ### Method Not Applicable (Function Call) ### Parameters (Specific parameters not detailed in the source text) ### Request Example (Not Applicable) ### Response (Not Applicable) ``` -------------------------------- ### espn_getendpoint_raw() Source: https://ffscrapr.ffverse.com/reference/index.html GET an ESPN endpoint in raw format. This function is optimized for the ESPN platform. ```APIDOC ## espn_getendpoint_raw() ### Description GET ESPN endpoint (raw). This function is optimized for the ESPN platform. ### Method Not Applicable (Function Call) ### Parameters (Specific parameters not detailed in the source text) ### Request Example (Not Applicable) ### Response (Not Applicable) ``` -------------------------------- ### espn_getendpoint() Source: https://ffscrapr.ffverse.com/reference/index.html GET an ESPN fantasy league endpoint. This function is optimized for the ESPN platform. ```APIDOC ## espn_getendpoint() ### Description GET ESPN fantasy league endpoint. This function is optimized for the ESPN platform. ### Method Not Applicable (Function Call) ### Parameters (Specific parameters not detailed in the source text) ### Request Example (Not Applicable) ### Response (Not Applicable) ``` -------------------------------- ### Create Default FFverse Template Connection Source: https://ffscrapr.ffverse.com/reference/ff_template.html Use this function to generate a connection object that mimics a real league connection. It's useful for testing functions like `ff_scoring()` and `ff_starterpositions()` without needing a live league connection. Specify scoring and roster types to customize the template. ```r ff_template( scoring_type = c("ppr", "half_ppr", "zero_ppr", "sfb11"), roster_type = c("1qb", "superflex", "sfb11", "idp") ) ``` -------------------------------- ### Get MFL Starter Positions Source: https://ffscrapr.ffverse.com/reference/ff_starter_positions.html Retrieves the minimum and maximum starters for each player position from an MFL connection. An MFL connection must be established using `mfl_connect()` prior to executing this function. ```R dlfidp_conn <- mfl_connect(2020, league_id = 33158) ff_starter_positions(conn = dlfidp_conn) ``` -------------------------------- ### Get Fleaflicker Standings Source: https://ffscrapr.ffverse.com/reference/ff_standings.html Connects to a Fleaflicker league and retrieves standings data. Use this for Fleaflicker leagues. ```r # \donttest{ try({ conn <- fleaflicker_connect(season = 2020, league_id = 206154) x <- ff_standings(conn) }) # end try # } ``` -------------------------------- ### Get ESPN Starter Positions Source: https://ffscrapr.ffverse.com/reference/ff_starter_positions.html Retrieves the minimum and maximum starters for each main player position from an ESPN connection. Ensure you have established an ESPN connection using `espn_connect()` before calling this function. ```R conn <- espn_connect(season = 2020, league_id = 1178049) ff_starter_positions(conn) ``` -------------------------------- ### Get MFL Standings Source: https://ffscrapr.ffverse.com/reference/ff_standings.html Connects to an MFL league and retrieves standings data. This method returns H2H/points/all-play/best-ball data. ```r # \donttest{ try({ ssb_conn <- ff_connect(platform = "mfl", league_id = 54040, season = 2020) ff_standings(ssb_conn) }) # end try #> Warning: There was 1 warning in `mutate()`. #> ℹ In argument: `fname = .Primitive("as.double")(fname)`. #> Caused by warning: #> ! NAs introduced by coercion #> # A tibble: 14 × 10 #> franchise_id franchise_name h2h_winpct h2h_wlt allplay_winpct points_for #> #> 1 0009 Team Link 0.769 10-3-0 0.725 2063. #> 2 0010 Team Yoshi 0.692 9-4-0 0.65 1956. #> 3 0014 Team Luigi 0.769 10-3-0 0.72 2086. #> 4 0003 Team Donkey Kong 0.462 6-7-0 0.615 1937. #> 5 0006 Team King Dedede 0.615 8-5-0 0.68 2138. #> 6 0011 Team Diddy Kong 0.615 8-5-0 0.56 1927. #> 7 0008 Team Bowser 0.538 7-6-0 0.462 1820. #> 8 0007 Team Kirby 0.538 7-6-0 0.545 1829. #> 9 0002 Team Simon Belmont 0.462 6-7-0 0.328 1623. #> 10 0004 Team Ice Climbers 0.385 5-8-0 0.495 1852. #> 11 0005 Team Dr. Mario 0.385 5-8-0 0.368 1698. #> 12 0013 Team Ness 0.231 3-10-0 0.26 1553. #> 13 0012 Team Mewtwo 0.308 4-9-0 0.396 1708. #> 14 0001 Team Pikachu 0.231 3-10-0 0.151 1459. #> # ℹ 4 more variables: points_against , avg_points_for , #> # avg_points_against , faab_balance # } ``` -------------------------------- ### Get ESPN Schedule Source: https://ffscrapr.ffverse.com/reference/ff_schedule.html Retrieves the schedule for a given ESPN league. Completed games include result data. ```R try({ espn_conn <- espn_connect(season = 2020, league_id = 899513) ff_schedule(espn_conn) }) # end try ``` -------------------------------- ### Create GitHub Fork and Clone Source: https://ffscrapr.ffverse.com/CONTRIBUTING.html Use this function to fork the package repository on GitHub and clone it to your local machine. ```r usethis::create_from_github("ffverse/ffscrapr", fork = TRUE) ``` -------------------------------- ### Fetch League Boxscore and Process Lineups Source: https://ffscrapr.ffverse.com/articles/fleaflicker_getendpoint.html This snippet demonstrates fetching league boxscore data for a specific game and processing the 'lineups' content. It's useful for analyzing player lineups in a given fantasy game and week. The data is then unnested and pivoted for easier analysis. ```R onegame_lineups <- fleaflicker_getendpoint( "FetchLeagueBoxscore", sport = sport, league_id = league_id, # example for one call, but you can call this in a map or loop! fantasy_game_id = df_scoreboard$id[[1]], scoring_period = week) %>% purrr::pluck('content','lineups') %>% tibble::tibble() %>% tidyr::unnest_wider(1) %>% tidyr::unnest_longer('slots') %>% tidyr::unnest_wider('slots') %>% tidyr::pivot_longer(c("home","away"),names_to = "franchise",values_to = "player") %>% tidyr::unnest_wider('player') str(onegame_lineups,max.level = 2) ``` -------------------------------- ### Get ffscrapr Cache Directory Source: https://ffscrapr.ffverse.com/articles/ffscrapr_caching.html Determine the default directory where ffscrapr will store cache files on your local filesystem. ```r rappdirs::user_cache_dir("ffscrapr") ``` -------------------------------- ### Get Transactions for a Specific League Source: https://ffscrapr.ffverse.com/reference/ff_transactions.html Fetches all transactions for a given league connection. Ensure the connection object is properly initialized. ```r library(fantasy)'; try({ dlf_conn <- mfl_connect(2019, league_id = 37920) ff_transactions(dlf_conn) }) ``` -------------------------------- ### ff_template() Source: https://ffscrapr.ffverse.com/reference/index.html Provides default connection objects. This is a primary function designed to work for all platforms. ```APIDOC ## ff_template() ### Description Default `conn` objects. This is a primary function designed to work for all platforms. ### Method Not Applicable (Function Call) ### Parameters (Specific parameters not detailed in the source text) ### Request Example (Not Applicable) ### Response (Not Applicable) ``` -------------------------------- ### Get MFL Schedule Source: https://ffscrapr.ffverse.com/reference/ff_schedule.html Retrieves the schedule for a given MyFantasyLeague (MFL) league. Completed games include result data. ```R try({ ssb_conn <- ff_connect(platform = "mfl", league_id = 54040, season = 2020) ff_schedule(ssb_conn) }) # end try ``` -------------------------------- ### Get Sleeper Franchises Source: https://ffscrapr.ffverse.com/reference/ff_franchises.html Connect to a Sleeper league and retrieve franchise information. Ensure you have the correct league ID and season. ```r jml_conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_franchises(jml_conn) ``` -------------------------------- ### Constructing an X-Fantasy-Filter Header Source: https://ffscrapr.ffverse.com/articles/espn_getendpoint.html Builds a JSON string for the `X-Fantasy-Filter` header to filter and sort player data, specifically limiting to the top 5 players by percentage owned and filtering by top scoring periods. ```r xff <- list(players = list( limit = 5, sortPercOwned = list(sortAsc = FALSE, sortPriority = 1), filterStatsForTopScoringPeriodIDs = list(value = 2, additionalValue = c(paste0("00", conn$season))) )) %>% jsonlite::toJSON(auto_unbox = TRUE) xff #> {"players":{"limit":5,"sortPercOwned":{"sortAsc":false,"sortPriority":1},"filterStatsForTopScoringPeriodIDs":{"value":2,"additionalValue":"002020"}}} ``` -------------------------------- ### Get MFL Franchises Source: https://ffscrapr.ffverse.com/reference/ff_franchises.html Connect to an MFL league and retrieve franchise information. Ensure you have the correct league ID and season. ```r ssb_conn <- ff_connect(platform = "mfl", league_id = 54040, season = 2020) ff_franchises(ssb_conn) ``` -------------------------------- ### Prepare Player ID Mappings Source: https://ffscrapr.ffverse.com/articles/espn_basics.html Create a mapping between ESPN player IDs and FantasyPros IDs by loading and filtering player ID data. This is necessary for joining external value data. ```r player_ids <- dp_playerids() %>% select(espn_id,fantasypros_id) %>% filter(!is.na(espn_id),!is.na(fantasypros_id)) ``` -------------------------------- ### Get Draft Picks (Sleeper) Source: https://ffscrapr.ffverse.com/reference/ff_draftpicks.html Retrieves current and future draft picks from Sleeper. Requires Sleeper connection details. ```r # \donttest{ try({ jml_conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_draftpicks(jml_conn) }) # } ``` -------------------------------- ### Get Sleeper Players Data Source: https://ffscrapr.ffverse.com/reference/sleeper_players.html Retrieves a dataframe containing all players from the Sleeper database. This function uses memoization for session-wide caching. ```r sleeper_players() ``` -------------------------------- ### Load ffscrapr Package Source: https://ffscrapr.ffverse.com/articles/mfl_getendpoint.html Load the ffscrapr package to begin using its functions. ```R library(ffscrapr) ``` -------------------------------- ### Get Scoring History from Fleaflicker Source: https://ffscrapr.ffverse.com/reference/ff_scoringhistory.html Retrieves historical scoring data for a specified season from Fleaflicker. Requires an active connection object. ```r try({ conn <- fleaflicker_connect(2020, 312861) ff_scoringhistory(conn, season = 2020) }) ``` -------------------------------- ### Initialize Git Branch for Pull Request Source: https://ffscrapr.ffverse.com/CONTRIBUTING.html Creates a new Git branch for your pull request, with a name describing the intended changes. ```r usethis::pr_init("brief-description-of-change") ``` -------------------------------- ### Load and Prepare Player Values Source: https://ffscrapr.ffverse.com/articles/fleaflicker_basics.html Load player values from a CSV file and player ID mappings. This involves joining Fleaflicker's sportradar IDs with external fantasypros IDs to enable value integration. ```R player_values <- dp_values("values-players.csv") player_ids <- dp_playerids() %>% select(sportradar_id,fantasypros_id) %>% filter(!is.na(sportradar_id),!is.na(fantasypros_id)) player_values <- player_values %>% left_join(player_ids, by = c("fp_id" = "fantasypros_id")) %>% select(sportradar_id,age,ecr_2qb,ecr_pos,value_2qb) ``` -------------------------------- ### ff_connect Source: https://ffscrapr.ffverse.com/reference/ff_connect.html Creates a connection object for a fantasy sports league. It handles parameter storage and attempts to retrieve a login cookie by passing arguments to a league-specific handler. ```APIDOC ## ff_connect ### Description Creates a connection object for a fantasy sports league. It handles parameter storage and attempts to retrieve a login cookie by passing arguments to a league-specific handler. ### Usage ```R ff_connect(platform = "mfl", league_id = NULL, ...) ``` ### Arguments * **platform** (character) - One of MFL or Sleeper (Fleaflicker, ESPN, Yahoo in approximate priority order going forward). * **league_id** (character) - League ID (currently assuming one league at a time). * **...** - Other parameters passed to the connect function for each specific platform. ### Value A connection object to be used with `ff_*` functions. ### See Also `mfl_connect()`, `sleeper_connect()`, `fleaflicker_connect()`, `espn_connect()` ### Examples ```R # \donttest{ ff_connect(platform = "mfl", season = 2019, league_id = 54040, rate_limit = FALSE) #> #> List of 5 #> $ platform : chr "MFL" #> $ season : num 2019 #> $ league_id : chr "54040" #> $ APIKEY : NULL #> $ auth_cookie: NULL #> - attr(*, "class")= chr "mfl_conn" # } ``` ``` -------------------------------- ### Get Draft Picks (MFL) Source: https://ffscrapr.ffverse.com/reference/ff_draftpicks.html Retrieves current and future draft picks from MyFantasyLeague (MFL). Requires MFL connection details. ```r # \donttest{ try({ dlf_conn <- mfl_connect(2020, league_id = 37920) ff_draftpicks(conn = dlf_conn) }) # } ``` -------------------------------- ### Fleaflicker: Get League Rosters Source: https://ffscrapr.ffverse.com/reference/ff_rosters.html Retrieves roster data for a Fleaflicker league connection. Note that age information is not currently returned by this method. ```r # \donttest{ try({ joe_conn <- ff_connect(platform = "fleaflicker", league_id = 312861, season = 2020) ff_rosters(joe_conn) }) # end try ``` -------------------------------- ### Get Sleeper League Scoring Source: https://ffscrapr.ffverse.com/reference/ff_scoring.html Retrieves the default scoring settings for a Sleeper fantasy football league. Ensure you have an active connection object. ```r jml_conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) ff_scoring(jml_conn) ``` -------------------------------- ### ff_connect() Source: https://ffscrapr.ffverse.com/reference/index.html Connect to a fantasy football league. This is a primary function designed to work for all platforms. ```APIDOC ## ff_connect() ### Description Connect to a fantasy football league. This is a primary function designed to work for all platforms. ### Method Not Applicable (Function Call) ### Parameters (Specific parameters not detailed in the source text) ### Request Example (Not Applicable) ### Response (Not Applicable) ``` -------------------------------- ### Get Fleaflicker Draft Results Source: https://ffscrapr.ffverse.com/reference/ff_draft.html Retrieves a table of draft results for the current year from Fleaflicker. Requires an active Fleaflicker connection object. ```R # try only shown here because sometimes CRAN checks are weird try({ conn <- fleaflicker_connect(season = 2020, league_id = 206154) ff_draft(conn) }) # end try #> # A tibble: 80 × 9 #> round pick overall franchise_id franchise_name player_id player_name pos #> #> 1 1 1 1 1373970 Bamenda Herd 15539 Clyde Edwa… RB #> 2 1 2 2 1374252 Central City Cr… 15604 Jonathan T… RB #> 3 1 3 3 1373991 Top City Terrors 15523 CeeDee Lamb WR #> 4 1 4 4 1374315 Shanghai Commun… 15555 J.K. Dobbi… RB #> 5 1 5 5 1374271 Clutch City Bal… 15563 Cam Akers RB #> 6 1 6 6 1374271 Clutch City Bal… 15563 Cam Akers RB #> 7 1 7 7 1373883 Manitoba Marmots 15540 Justin Jef… WR #> 8 1 8 8 1373973 Red River Land … 15544 Jerry Jeudy WR #> 9 1 9 9 1374271 Clutch City Bal… 15537 Chase Young EDR #> 10 1 10 10 1373535 Winterthur Angr… 15620 Ke'Shawn V… RB #> # ℹ 70 more rows #> # ℹ 1 more variable: team # ``` -------------------------------- ### Load Required Libraries Source: https://ffscrapr.ffverse.com/articles/sleeper_getendpoint.html Load the necessary libraries for API interaction and data manipulation. ```R library(ffscrapr) library(dplyr) library(purrr) library(glue) ``` -------------------------------- ### Get Transactions Source: https://ffscrapr.ffverse.com/index.html Retrieves transaction history for the fantasy league using ff_transactions(). The function returns a tibble detailing trades and other league activities. ```r # Get transactions ff_transactions(ssb) #> # A tibble: 1,145 × 12 #> timestamp type type_desc franchise_id franchise_name #> #> 1 2021-02-12 14:32:39 TRADE traded_away 0008 Team Bowser #> 2 2021-02-12 14:32:39 TRADE traded_for 0008 Team Bowser #> 3 2021-02-12 14:32:39 TRADE traded_for 0008 Team Bowser #> 4 2021-02-12 14:32:39 TRADE traded_for 0008 Team Bowser #> 5 2021-02-12 14:32:39 TRADE traded_for 0008 Team Bowser #> # … with 1,140 more rows, and 7 more variables: player_id , #> # player_name , pos , team , bbid_spent , #> # trade_partner , comments #> # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names ```