Fantasy Football Data

library(fflr)
packageVersion("fflr")
#> [1] '2.3.0'
ffl_id(leagueId = "42654852")
#> Temporarily set `fflr.leagueId` option to 42654852
#> [1] "42654852"

This vignette will demonstrate the fflr functions used to reach equivalency with the ESPN fantasy football website. The website has eight section headers with various subsections:

  1. My Team
  2. League
  3. Players
  4. FantasyCast
  5. Scoreboard
  6. Standings
  7. Opposing Teams
  8. LM Tools

My Team

The My Team page presents an overview of, well, your fantasy team. From this page, a team manager can set their lineup and see statistics and news on the players on their roster.

There are six subsections on the My Team page.

Overview

The team_roster() function returns all rosters in a league. The output of this function is organized to replicate the layout of the table found on the website. Players are listed in order of their “slot” with name and team information followed by projected and actual scores and ownership statistics.

my_team <- team_roster(scoringPeriodId = 1, leagueHistory = TRUE)[[1]] # select first roster
my_team[[1]][, -(1:3)]
#> # A tibble: 16 × 13
#>    abbrev lineupSlot playerId firstName  lastName  proTeam position injuryStatus
#>    <fct>  <fct>         <int> <chr>      <chr>     <fct>   <fct>    <chr>       
#>  1 AUS    RB          4242335 Jonathan   Taylor    Ind     RB       A           
#>  2 AUS    RB          4259545 D'Andre    Swift     Det     RB       A           
#>  3 AUS    WR            16800 Davante    Adams     GB      WR       A           
#>  4 AUS    WR            16460 Adam       Thielen   Min     WR       Q           
#>  5 AUS    TE          3116365 Mark       Andrews   Bal     TE       A           
#>  6 AUS    FLEX        3932905 Diontae    Johnson   Pit     WR       A           
#>  7 AUS    D/ST         -16027 Buccaneers D/ST      TB      D/ST     A           
#>  8 AUS    K           2473037 Jason      Myers     Sea     K        A           
#>  9 AUS    BE          3117251 Christian  McCaffrey Car     RB       Q           
#> 10 AUS    BE          4360294 Antonio    Gibson    Wsh     RB       A           
#> 11 AUS    BE          3925357 Calvin     Ridley    Atl     WR       O           
#> 12 AUS    BE          4045163 Miles      Sanders   Phi     RB       A           
#> 13 AUS    BE          3919596 Chris      Carson    Sea     RB       Q           
#> 14 AUS    BE          3128429 Courtland  Sutton    Den     WR       A           
#> 15 AUS    BE          2577417 Dak        Prescott  Dal     QB       A           
#> 16 AUS    BE          3128720 Nick       Chubb     Cle     RB       A           
#> # ℹ 5 more variables: projectedScore <dbl>, actualScore <dbl>, percentStarted <dbl>,
#> #   percentOwned <dbl>, percentChange <dbl>

News

The player_outlook() and player_news() functions return news on your roster. The first returns all outlooks by player and week and cannot be refined beyond setting a limit of players to return (in order of rank).

player_outlook(limit = 1)
#> # A tibble: 1 × 5
#>   seasonId      id firstName lastName outlook
#>      <int>   <int> <chr>     <chr>    <chr>  
#> 1     2024 3116406 Tyreek    Hill     <NA>

The second fiction takes a single playerId value and returns all the recent news on that player, including premium stories in HTML format.

player_news(playerId = "3139477", parseHTML = FALSE)
#> # A tibble: 2 × 6
#>        id published           type         premium headline                          body 
#>     <int> <dttm>              <chr>        <lgl>   <chr>                             <chr>
#> 1 3139477 2024-04-23 21:14:33 Story        FALSE   Max Strus' buzzer-beater shocks … "<p>…
#> 2 3139477 2024-04-11 12:00:24 HeadlineNews FALSE   Rees-Zammit reveals texts from M… "<p>…

League

ESPN fantasy leagues have their own unique settings and structure. This package has been tested for a very narrow subset of those possible settings.

league_info(leagueId = "42654852")
#> # A tibble: 1 × 6
#>         id seasonId name             isPublic  size finalScoringPeriod
#>      <int>    <int> <chr>            <lgl>    <int>              <int>
#> 1 42654852     2024 FFLR Test League TRUE         4                 17
league_name()
#> [1] "FFLR Test League"
league_size()
#> # A tibble: 1 × 2
#>   seasonId  size
#>      <int> <int>
#> 1     2024     4
str(league_status())
#> tibble [1 × 12] (S3: tbl_df/tbl/data.frame)
#>  $ year                   : int 2024
#>  $ isActive               : logi TRUE
#>  $ activatedDate          : POSIXct[1:1], format: "2024-05-02 20:28:18"
#>  $ scoringPeriodId        : int 0
#>  $ firstScoringPeriod     : int 1
#>  $ finalScoringPeriod     : int 17
#>  $ previousSeasons        :List of 1
#>   ..$ : int [1:3] 2021 2022 2023
#>  $ standingsUpdateDate    : POSIXct[1:1], format: NA
#>  $ teamsJoined            : int 4
#>  $ waiverLastExecutionDate: POSIXct[1:1], format: "2024-05-02 20:28:18"
#>  $ waiverNextExecutionDate: POSIXct[1:1], format: NA
#>  $ waiverProcessStatus    :List of 1
#>   ..$ :'data.frame': 0 obs. of  1 variable:
#>   .. ..$ date: 'POSIXct' num(0) 
#>  - attr(*, "tzone")= chr ""

Settings

Draft

draft_settings()
#> # A tibble: 1 × 13
#>   seasonId auctionBudget isTradingEnabled keeperCount keeperCountFuture keeperOrderType
#>      <int> <chr>         <lgl>                  <int>             <int> <chr>          
#> 1     2024 <NA>          FALSE                      2                 2 TRADITIONAL    
#> # ℹ 7 more variables: leagueSubType <chr>, orderType <chr>, pickOrder <list>,
#> #   timePerSelection <int>, type <chr>, availableDate <dttm>, date <dttm>

Rosters

roster_settings()
#> # A tibble: 1 × 8
#>   seasonId isBenchUnlimited isUsingUndroppableList lineupLocktimeType lineupSlotCounts
#>      <int> <lgl>            <lgl>                  <chr>              <list>          
#> 1     2024 TRUE             TRUE                   INDIVIDUAL_GAME    <df [25 × 2]>   
#> # ℹ 3 more variables: moveLimit <int>, positionLimits <list>, rosterLocktimeType <chr>

Scoring

scoring_settings()
#> # A tibble: 1 × 7
#>   seasonId scoringType playerRankType homeTeamBonus playoffHomeTeamBonus
#>      <int> <chr>       <chr>                  <int>                <int>
#> 1     2024 H2H_POINTS  PPR                        1                    0
#> # ℹ 2 more variables: playoffMatchupTieRule <chr>, scoringItems <list>

Transactions and Keepers

acquisition_settings()
#> # A tibble: 1 × 12
#>    year acquisitionBudget acquisitionLimit acquisitionType     finalPlaceTransactionElig…¹
#>   <int>             <int>            <int> <chr>                                     <int>
#> 1  2024               100               -1 WAIVERS_TRADITIONAL                           0
#> # ℹ abbreviated name: ¹​finalPlaceTransactionEligible
#> # ℹ 7 more variables: matchupLimitPerScoringPeriod <lgl>, minimumBid <int>,
#> #   transactionLockingEnabled <lgl>, waiverHours <int>, waiverOrderReset <lgl>,
#> #   waiverProcessDays <list>, waiverProcessHour <int>

Schedule

schedule_settings()
#> # A tibble: 1 × 12
#>   seasonId divisions    matchupPeriodCount matchupPeriodLength matchupPeriods periodTypeId
#>      <int> <list>                    <int>               <int> <list>                <int>
#> 1     2024 <df [2 × 3]>                 17                   1 <df [17 × 2]>             1
#> # ℹ 6 more variables: playoffMatchupPeriodLength <int>, playoffReseed <lgl>,
#> #   playoffSeedingRule <chr>, playoffSeedingRuleBy <int>, playoffTeamCount <int>,
#> #   variablePlayoffMatchupPeriodLength <lgl>

Members

league_members()
#> # A tibble: 1 × 6
#>   memberId                  displayName firstName lastName isLeagueCreator isLeagueManager
#>   <chr>                     <chr>       <chr>     <chr>    <lgl>           <lgl>          
#> 1 {22DFE7FF-9DF2-4F3B-9FE7… K5cents     Kiernan   Nicholls TRUE            FALSE

Rosters

team_roster(scoringPeriodId = 1)
#> League has not yet drafted this season
#> data frame with 0 columns and 0 rows

Schedule

tidy_schedule(scoringPeriodId = 1)
#> # A tibble: 68 × 7
#>    seasonId matchupPeriodId matchupId teamId abbrev opponent isHome
#>       <int>           <int>     <int>  <int> <fct>  <fct>    <lgl> 
#>  1     2024               1         1      1 AUS    CHI      TRUE  
#>  2     2024               1         1      3 CHI    AUS      FALSE 
#>  3     2024               1         2      2 BOS    DEN      TRUE  
#>  4     2024               1         2      4 DEN    BOS      FALSE 
#>  5     2024               2         3      3 CHI    DEN      TRUE  
#>  6     2024               2         3      4 DEN    CHI      FALSE 
#>  7     2024               2         4      1 AUS    BOS      TRUE  
#>  8     2024               2         4      2 BOS    AUS      FALSE 
#>  9     2024               3         5      4 DEN    AUS      TRUE  
#> 10     2024               3         5      1 AUS    DEN      FALSE 
#> # ℹ 58 more rows

Message Board

league_messages(scoringPeriodId = 1)
#> # A tibble: 1 × 7
#>   id       type  author                    date                content messages viewableBy
#>   <chr>    <chr> <chr>                     <dttm>              <chr>   <list>   <list>    
#> 1 5af42ec9 NOTE  {22DFE7FF-9DF2-4F3B-9FE7… 2021-09-13 19:46:07 This [… <NULL>   <NULL>

Transaction Counter

transaction_counter()
#> # A tibble: 4 × 14
#>   seasonId scoringPeriodId teamId abbrev waiverRank acquisitionBudgetSpent acquisitions
#>      <int>           <int>  <int> <fct>       <int>                  <int>        <int>
#> 1     2024               0      1 AUS             2                      0            0
#> 2     2024               0      2 BOS             4                      0            0
#> 3     2024               0      3 CHI             3                      0            0
#> 4     2024               0      4 DEN             1                      0            0
#> # ℹ 7 more variables: drops <int>, misc <int>, moveToActive <int>, moveToIR <int>,
#> #   paid <dbl>, teamCharges <dbl>, trades <int>

Draft Recap

draft_recap()
#> # A tibble: 64 × 15
#>    seasonId autoDraftTypeId bidAmount pickId keeper lineupSlot nominatingTeamId
#>       <int>           <int>     <int>  <int> <lgl>  <fct>      <fct>           
#>  1     2024               0        NA      1 FALSE  QB         <NA>            
#>  2     2024               0        NA      2 FALSE  QB         <NA>            
#>  3     2024               0        NA      3 FALSE  QB         <NA>            
#>  4     2024               0        NA      4 FALSE  QB         <NA>            
#>  5     2024               0        NA      5 FALSE  QB         <NA>            
#>  6     2024               0        NA      6 FALSE  QB         <NA>            
#>  7     2024               0        NA      7 FALSE  QB         <NA>            
#>  8     2024               0        NA      8 FALSE  QB         <NA>            
#>  9     2024               0        NA      9 FALSE  QB         <NA>            
#> 10     2024               0        NA     10 FALSE  QB         <NA>            
#> # ℹ 54 more rows
#> # ℹ 8 more variables: overallPickNumber <int>, playerId <int>, reservedForKeeper <lgl>,
#> #   roundId <int>, roundPickNumber <int>, teamId <int>, abbrev <fct>, tradeLocked <lgl>

Recent Activity

recent_activity(scoringPeriodId = 1)
#> no roster moves for current period
#> data frame with 0 columns and 0 rows

Players

list_players(limit = 10, proTeam = "Mia", status = "ALL")
#> # A tibble: 10 × 19
#>    seasonId scoringPeriodId      id firstName lastName   proTeam defaultPosition
#>       <int>           <dbl>   <int> <chr>     <chr>      <fct>   <fct>          
#>  1     2023               1 3116406 Tyreek    Hill       Mia     WR             
#>  2     2023               1 2576414 Raheem    Mostert    Mia     RB             
#>  3     2023               1 4372016 Jaylen    Waddle     Mia     WR             
#>  4     2023               1 4429160 De'Von    Achane     Mia     RB             
#>  5     2023               1 4241479 Tua       Tagovailoa Mia     QB             
#>  6     2023               1  -16015 Dolphins  D/ST       Mia     D/ST           
#>  7     2023               1 3124679 Jason     Sanders    Mia     K              
#>  8     2023               1 3122976 Jeff      Wilson Jr. Mia     RB             
#>  9     2023               1 3054212 Jonnu     Smith      Mia     TE             
#> 10     2023               1 4046692 Chase     Claypool   Mia     WR             
#> # ℹ 12 more variables: injuryStatus <chr>, percentStarted <dbl>, percentOwned <dbl>,
#> #   percentChange <dbl>, positionalRanking <int>, totalRating <dbl>,
#> #   auctionValueAverage <dbl>, averageDraftPosition <dbl>, projectedScore <dbl>,
#> #   lastScore <dbl>, lastSeason <dbl>, currentSeason <dbl>

Scoreboard

live_scoring()
#> League has not yet drafted this season
#> data frame with 0 columns and 0 rows

Standings

league_standings()
#> # A tibble: 4 × 17
#>   seasonId scoringPeriodId teamId abbrev draftDayProjectedRank currentProjectedRank
#>      <int>           <int>  <int> <fct>                  <int>                <int>
#> 1     2024               0      1 AUS                        0                    0
#> 2     2024               0      2 BOS                        0                    0
#> 3     2024               0      3 CHI                        0                    0
#> 4     2024               0      4 DEN                        0                    0
#> # ℹ 11 more variables: playoffSeed <int>, rankCalculatedFinal <int>, gamesBack <dbl>,
#> #   losses <int>, percentage <dbl>, pointsAgainst <dbl>, pointsFor <dbl>,
#> #   streakLength <int>, streakType <chr>, ties <int>, wins <int>