Fantasy Football Data

library(fflr)
packageVersion("fflr")
#> [1] '2.0.3'
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)[[1]] # select first roster
my_team[, -(1:3)]
#> # A tibble: 16 × 13
#>    abbrev lineupSlot playerId firstName  lastName    proTeam position injuryStatus
#>    <fct>  <fct>         <int> <chr>      <chr>       <fct>   <fct>    <chr>       
#>  1 AUS    QB          3139477 Patrick    Mahomes     KC      QB       A           
#>  2 AUS    RB          3117251 Christian  McCaffrey   Car     RB       Q           
#>  3 AUS    RB          4242335 Jonathan   Taylor      Ind     RB       A           
#>  4 AUS    WR            16800 Davante    Adams       GB      WR       A           
#>  5 AUS    WR          3925357 Calvin     Ridley      Atl     WR       O           
#>  6 AUS    TE          3116365 Mark       Andrews     Bal     TE       A           
#>  7 AUS    FLEX        4360294 Antonio    Gibson      Wsh     RB       A           
#>  8 AUS    D/ST         -16027 Buccaneers D/ST        TB      D/ST     A           
#>  9 AUS    K           2473037 Jason      Myers       Sea     K        A           
#> 10 AUS    BE          4259545 D'Andre    Swift       Det     RB       A           
#> 11 AUS    BE          4045163 Miles      Sanders     Phi     RB       A           
#> 12 AUS    BE          3919596 Chris      Carson      Sea     RB       Q           
#> 13 AUS    BE            16799 Allen      Robinson II Chi     WR       A           
#> 14 AUS    BE            16460 Adam       Thielen     Min     WR       Q           
#> 15 AUS    BE          3932905 Diontae    Johnson     Pit     WR       A           
#> 16 AUS    BE          3128429 Courtland  Sutton      Den     WR       A           
#> # … with 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     2021 3116593 Dalvin    Cook     <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: 5 × 6
#>        id published           type     premium headline                              body 
#>     <int> <dttm>              <chr>    <lgl>   <chr>                                 <chr>
#> 1 3139477 2022-03-23 17:20:26 Rotowire FALSE   Mahomes will have to contend with a … "In …
#> 2 3139477 2022-02-18 16:40:57 Story    FALSE   2022 NFL predictions: Experts debate… "<p>…
#> 3 3139477 2022-01-30 23:34:02 Rotowire FALSE   Mahomes completed 26 of 39 passes fo… "Mah…
#> 4 3139477 2022-01-24 06:18:16 Rotowire FALSE   Mahomes completed 33 of 44 passes fo… "Mah…
#> 5 3139477 2022-01-17 05:17:57 Rotowire FALSE   Mahomes completed 30 of 39 pass atte… "Mah…

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     2021 FFLR Test League TRUE         4                 17
league_name()
#> [1] "FFLR Test League"
league_size()
#> # A tibble: 1 × 2
#>   seasonId  size
#>      <int> <int>
#> 1     2021     4
str(league_status())
#> tibble [1 × 12] (S3: tbl_df/tbl/data.frame)
#>  $ year                   : int 2021
#>  $ isActive               : logi TRUE
#>  $ activatedDate          : POSIXct[1:1], format: "2021-08-03 10:40:01"
#>  $ scoringPeriodId        : int 19
#>  $ firstScoringPeriod     : int 1
#>  $ finalScoringPeriod     : int 17
#>  $ previousSeasons        :List of 1
#>   ..$ : list()
#>  $ standingsUpdateDate    : POSIXct[1:1], format: "2022-01-10 05:03:39"
#>  $ teamsJoined            : int 4
#>  $ waiverLastExecutionDate: POSIXct[1:1], format: "2022-01-13 04:25:06"
#>  $ waiverNextExecutionDate: POSIXct[1:1], format: NA
#>  $ waiverProcessStatus    :List of 1
#>   ..$ :'data.frame': 1 obs. of  2 variables:
#>   .. ..$ date  : POSIXct[1:1], format: "2021-09-29"
#>   .. ..$ status: int 2

Settings

Draft

draft_settings()
#> # A tibble: 1 × 13
#>   seasonId auctionBudget availableDate       date                isTradingEnabled
#>      <int> <chr>         <dttm>              <dttm>              <lgl>           
#> 1     2021 <NA>          2021-08-03 10:15:00 2021-08-03 11:15:00 FALSE           
#> # … with 8 more variables: keeperCount <int>, keeperCountFuture <int>,
#> #   keeperOrderType <chr>, leagueSubType <chr>, orderType <chr>, pickOrder <list>,
#> #   timePerSelection <int>, type <chr>

Rosters

roster_settings()
#> # A tibble: 1 × 8
#>   seasonId isBenchUnlimited isUsingUndroppabl… lineupLocktimeT… lineupSlotCounts moveLimit
#>      <int> <lgl>            <lgl>              <chr>            <list>               <int>
#> 1     2021 TRUE             TRUE               INDIVIDUAL_GAME  <df [25 × 2]>           -1
#> # … with 2 more variables: positionLimits <list>, rosterLocktimeType <chr>

Scoring

scoring_settings()
#> # A tibble: 1 × 7
#>   seasonId scoringType playerRankType homeTeamBonus playoffHomeTeamBonus playoffMatchupTi…
#>      <int> <chr>       <chr>                  <int>                <int> <chr>            
#> 1     2021 H2H_POINTS  PPR                        1                    0 NONE             
#> # … with 1 more variable: scoringItems <list>

Transactions and Keepers

acquisition_settings()
#> # A tibble: 1 × 10
#>    year acquisitionBudget acquisitionLimit acquisitionType     isUsingAcquisit… minimumBid
#>   <int>             <int>            <int> <chr>               <lgl>                 <int>
#> 1  2021               100               -1 WAIVERS_TRADITIONAL FALSE                     1
#> # … with 4 more variables: waiverHours <int>, waiverOrderReset <lgl>,
#> #   waiverProcessDays <list>, waiverProcessHour <int>

Schedule

schedule_settings()
#> # A tibble: 1 × 10
#>   seasonId divisions    matchupPeriodCount matchupPeriodLength matchupPeriods periodTypeId
#>      <int> <list>                    <int>               <int> <list>                <int>
#> 1     2021 <df [2 × 3]>                 17                   1 <df [17 × 2]>             1
#> # … with 4 more variables: playoffMatchupPeriodLength <int>, playoffSeedingRule <chr>,
#> #   playoffSeedingRuleBy <int>, playoffTeamCount <int>

Members

league_members()
#> # A tibble: 1 × 3
#>   displayName memberId                               isLeagueManager
#>   <chr>       <chr>                                  <lgl>          
#> 1 K5cents     {22DFE7FF-9DF2-4F3B-9FE7-FF9DF2AF3BD2} FALSE

Rosters

team_roster(scoringPeriodId = 1)
#> $AUS
#> # A tibble: 16 × 16
#>    seasonId scoringPeriodId teamId abbrev lineupSlot playerId firstName  lastName  proTeam
#>       <int>           <int>  <int> <fct>  <fct>         <int> <chr>      <chr>     <fct>  
#>  1     2021               1      1 AUS    QB          3139477 Patrick    Mahomes   KC     
#>  2     2021               1      1 AUS    RB          3117251 Christian  McCaffrey Car    
#>  3     2021               1      1 AUS    RB          4242335 Jonathan   Taylor    Ind    
#>  4     2021               1      1 AUS    WR            16800 Davante    Adams     GB     
#>  5     2021               1      1 AUS    WR          3925357 Calvin     Ridley    Atl    
#>  6     2021               1      1 AUS    TE          3116365 Mark       Andrews   Bal    
#>  7     2021               1      1 AUS    FLEX        4360294 Antonio    Gibson    Wsh    
#>  8     2021               1      1 AUS    D/ST         -16027 Buccaneers D/ST      TB     
#>  9     2021               1      1 AUS    K           2473037 Jason      Myers     Sea    
#> 10     2021               1      1 AUS    BE          4259545 D'Andre    Swift     Det    
#> 11     2021               1      1 AUS    BE          4045163 Miles      Sanders   Phi    
#> 12     2021               1      1 AUS    BE          3919596 Chris      Carson    Sea    
#> 13     2021               1      1 AUS    BE            16799 Allen      Robinson… Chi    
#> 14     2021               1      1 AUS    BE            16460 Adam       Thielen   Min    
#> 15     2021               1      1 AUS    BE          3932905 Diontae    Johnson   Pit    
#> 16     2021               1      1 AUS    BE          3128429 Courtland  Sutton    Den    
#> # … with 7 more variables: position <fct>, injuryStatus <chr>, projectedScore <dbl>,
#> #   actualScore <dbl>, percentStarted <dbl>, percentOwned <dbl>, percentChange <dbl>
#> 
#> $BOS
#> # A tibble: 16 × 16
#>    seasonId scoringPeriodId teamId abbrev lineupSlot playerId firstName lastName   proTeam
#>       <int>           <int>  <int> <fct>  <fct>         <int> <chr>     <chr>      <fct>  
#>  1     2021               1      2 BOS    QB          2577417 Dak       Prescott   Dal    
#>  2     2021               1      2 BOS    RB          3116593 Dalvin    Cook       Min    
#>  3     2021               1      2 BOS    RB          3051392 Ezekiel   Elliott    Dal    
#>  4     2021               1      2 BOS    WR          3116406 Tyreek    Hill       KC     
#>  5     2021               1      2 BOS    WR          4047650 DK        Metcalf    Sea    
#>  6     2021               1      2 BOS    TE          3040151 George    Kittle     SF     
#>  7     2021               1      2 BOS    FLEX        3128720 Nick      Chubb      Cle    
#>  8     2021               1      2 BOS    D/ST         -16023 Steelers  D/ST       Pit    
#>  9     2021               1      2 BOS    K             16339 Brandon   McManus    Den    
#> 10     2021               1      2 BOS    BE          4242214 Clyde     Edwards-H… KC     
#> 11     2021               1      2 BOS    BE          3121422 Terry     McLaurin   Wsh    
#> 12     2021               1      2 BOS    BE          2976499 Amari     Cooper     Dal    
#> 13     2021               1      2 BOS    BE          4039359 Darrell   Henderson… LAR    
#> 14     2021               1      2 BOS    BE            13982 Julio     Jones      Ten    
#> 15     2021               1      2 BOS    BE          2977187 Cooper    Kupp       LAR    
#> 16     2021               1      2 BOS    BE          2974858 Kenny     Golladay   NYG    
#> # … with 7 more variables: position <fct>, injuryStatus <chr>, projectedScore <dbl>,
#> #   actualScore <dbl>, percentStarted <dbl>, percentOwned <dbl>, percentChange <dbl>
#> 
#> $CHI
#> # A tibble: 16 × 16
#>    seasonId scoringPeriodId teamId abbrev lineupSlot playerId firstName lastName  proTeam
#>       <int>           <int>  <int> <fct>  <fct>         <int> <chr>     <chr>     <fct>  
#>  1     2021               1      3 CHI    QB          3918298 Josh      Allen     Buf    
#>  2     2021               1      3 CHI    RB          3929630 Saquon    Barkley   NYG    
#>  3     2021               1      3 CHI    RB          3043078 Derrick   Henry     Ten    
#>  4     2021               1      3 CHI    WR            15795 DeAndre   Hopkins   Ari    
#>  5     2021               1      3 CHI    WR          4262921 Justin    Jefferson Min    
#>  6     2021               1      3 CHI    TE          2576925 Darren    Waller    LV     
#>  7     2021               1      3 CHI    FLEX        3068267 Austin    Ekeler    LAC    
#>  8     2021               1      3 CHI    D/ST         -16033 Ravens    D/ST      Bal    
#>  9     2021               1      3 CHI    K             15683 Justin    Tucker    Bal    
#> 10     2021               1      3 CHI    BE          3116385 Joe       Mixon     Cin    
#> 11     2021               1      3 CHI    BE            15818 Keenan    Allen     LAC    
#> 12     2021               1      3 CHI    BE            16737 Mike      Evans     TB     
#> 13     2021               1      3 CHI    BE          4047365 Josh      Jacobs    LV     
#> 14     2021               1      3 CHI    BE          3886818 Myles     Gaskin    Mia    
#> 15     2021               1      3 CHI    BE          4362628 Ja'Marr   Chase     Cin    
#> 16     2021               1      3 CHI    BE          4360438 Brandon   Aiyuk     SF     
#> # … with 7 more variables: position <fct>, injuryStatus <chr>, projectedScore <dbl>,
#> #   actualScore <dbl>, percentStarted <dbl>, percentOwned <dbl>, percentChange <dbl>
#> 
#> $DEN
#> # A tibble: 16 × 16
#>    seasonId scoringPeriodId teamId abbrev lineupSlot playerId firstName lastName   proTeam
#>       <int>           <int>  <int> <fct>  <fct>         <int> <chr>     <chr>      <fct>  
#>  1     2021               1      4 DEN    QB          3917315 Kyler     Murray     Ari    
#>  2     2021               1      4 DEN    RB          3054850 Alvin     Kamara     NO     
#>  3     2021               1      4 DEN    RB          3042519 Aaron     Jones      GB     
#>  4     2021               1      4 DEN    WR          2976212 Stefon    Diggs      Buf    
#>  5     2021               1      4 DEN    WR          4047646 A.J.      Brown      Ten    
#>  6     2021               1      4 DEN    TE            15847 Travis    Kelce      KC     
#>  7     2021               1      4 DEN    FLEX        4241457 Najee     Harris     Pit    
#>  8     2021               1      4 DEN    D/ST         -16025 49ers     D/ST       SF     
#>  9     2021               1      4 DEN    K           3055899 Harrison  Butker     KC     
#> 10     2021               1      4 DEN    BE          4035538 David     Montgomery Chi    
#> 11     2021               1      4 DEN    BE          4241985 J.K.      Dobbins    Bal    
#> 12     2021               1      4 DEN    BE            15880 Robert    Woods      LAR    
#> 13     2021               1      4 DEN    BE          4241389 CeeDee    Lamb       Dal    
#> 14     2021               1      4 DEN    BE          3915416 DJ        Moore      Car    
#> 15     2021               1      4 DEN    BE          3116165 Chris     Godwin     TB     
#> 16     2021               1      4 DEN    BE          2577327 Tyler     Lockett    Sea    
#> # … with 7 more variables: position <fct>, injuryStatus <chr>, projectedScore <dbl>,
#> #   actualScore <dbl>, percentStarted <dbl>, percentOwned <dbl>, percentChange <dbl>

Schedule

tidy_matchups(scoringPeriodId = 1)
#> Warning: 'tidy_matchups' is deprecated.
#> Use 'tidy_schedule' instead.
#> See help("Deprecated")
#> # A tibble: 68 × 7
#>    seasonId matchupPeriodId matchupId teamId abbrev opponent isHome
#>       <int>           <int>     <int>  <int> <fct>  <fct>    <lgl> 
#>  1     2021               1         1      1 AUS    CHI      TRUE  
#>  2     2021               1         1      3 CHI    AUS      FALSE 
#>  3     2021               1         2      2 BOS    DEN      TRUE  
#>  4     2021               1         2      4 DEN    BOS      FALSE 
#>  5     2021               2         3      3 CHI    DEN      TRUE  
#>  6     2021               2         3      4 DEN    CHI      FALSE 
#>  7     2021               2         4      1 AUS    BOS      TRUE  
#>  8     2021               2         4      2 BOS    AUS      FALSE 
#>  9     2021               3         5      4 DEN    AUS      TRUE  
#> 10     2021               3         5      1 AUS    DEN      FALSE 
#> # … with 58 more rows

Message Board

league_messages(scoringPeriodId = 1)
#> # A tibble: 3 × 7
#>   id       type            author          date                content messages viewableBy
#>   <chr>    <chr>           <chr>           <dttm>              <chr>   <list>   <list>    
#> 1 a2d0d0b6 MSG_BOARD_GROUP {22DFE7FF-9DF2… 2021-09-13 19:46:29 "This … <df>     <NULL>    
#> 2 1e760139 MSG_BOARD       {22DFE7FF-9DF2… 2021-09-13 19:46:49 "This … <df>     <NULL>    
#> 3 5af42ec9 NOTE            {22DFE7FF-9DF2… 2021-09-13 19:46:07 "This … <NULL>   <NULL>

Transaction Counter

transaction_counter()
#> # A tibble: 4 × 14
#>   seasonId scoringPeriodId teamId abbrev waiverRank acquisitionBudgetS… acquisitions drops
#>      <int>           <int>  <int> <fct>       <int>               <int>        <int> <int>
#> 1     2021              19      1 AUS             2                   0            0     0
#> 2     2021              19      2 BOS             1                   0            0     0
#> 3     2021              19      3 CHI             3                   0            2     2
#> 4     2021              19      4 DEN             4                   0            2     1
#> # … with 6 more variables: 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     2021               1        NA      1 FALSE  RB         <NA>            
#>  2     2021               1        NA      2 FALSE  RB         <NA>            
#>  3     2021               1        NA      3 FALSE  RB         <NA>            
#>  4     2021               1        NA      4 FALSE  TE         <NA>            
#>  5     2021               1        NA      5 FALSE  RB         <NA>            
#>  6     2021               1        NA      6 FALSE  RB         <NA>            
#>  7     2021               1        NA      7 FALSE  RB         <NA>            
#>  8     2021               1        NA      8 FALSE  RB         <NA>            
#>  9     2021               1        NA      9 FALSE  WR         <NA>            
#> 10     2021               1        NA     10 FALSE  WR         <NA>            
#> # … with 54 more rows, and 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)
#> # A tibble: 68 × 16
#>    bidAmount executionType id            isActingAsTeamO… isLeagueManager isPending items 
#>        <int> <chr>         <chr>         <lgl>            <lgl>           <lgl>     <list>
#>  1         0 EXECUTE       93626cf5-095… FALSE            FALSE           FALSE     <df>  
#>  2         0 EXECUTE       241ffb13-b0f… FALSE            FALSE           FALSE     <df>  
#>  3         0 EXECUTE       8f85d38b-813… FALSE            FALSE           FALSE     <df>  
#>  4         0 EXECUTE       4f4b2063-d7b… FALSE            FALSE           FALSE     <NULL>
#>  5         0 EXECUTE       252e3cc0-036… FALSE            FALSE           FALSE     <df>  
#>  6         0 EXECUTE       612c9fd8-4ae… FALSE            FALSE           FALSE     <df>  
#>  7         0 EXECUTE       6c658f84-700… FALSE            FALSE           FALSE     <df>  
#>  8         0 EXECUTE       a6480853-49e… FALSE            FALSE           FALSE     <df>  
#>  9         0 EXECUTE       9ab9e6f4-a5f… FALSE            FALSE           FALSE     <df>  
#> 10         0 EXECUTE       aecfefda-9ef… FALSE            FALSE           FALSE     <NULL>
#> # … with 58 more rows, and 9 more variables: proposedDate <dttm>, scoringPeriodId <int>,
#> #   skipTransactionCounters <lgl>, status <chr>, teamId <int>, type <chr>,
#> #   memberId <chr>, relatedTransactionId <chr>, processDate <dttm>

Players

list_players(limit = 10)
#> # A tibble: 10 × 19
#>    seasonId scoringPeriodId     id firstName lastName proTeam defaultPosition injuryStatus
#>       <int>           <dbl>  <int> <chr>     <chr>    <fct>   <fct>           <chr>       
#>  1     2021               1 3.13e6 Deebo     Samuel   SF      WR              A           
#>  2     2021               1 2.33e3 Tom       Brady    TB      QB              A           
#>  3     2021               1 4.04e6 Justin    Herbert  LAC     QB              A           
#>  4     2021               1 1.32e4 Rob       Gronkow… TB      TE              A           
#>  5     2021               1 4.36e6 Kyle      Pitts    Atl     TE              A           
#>  6     2021               1 1.58e4 Cordarre… Patters… Atl     RB              A           
#>  7     2021               1 8.44e3 Aaron     Rodgers  GB      QB              A           
#>  8     2021               1 1.25e4 Matthew   Stafford LAR     QB              A           
#>  9     2021               1 4.37e6 Jaylen    Waddle   Mia     WR              A           
#> 10     2021               1 3.05e6 James     Conner   Ari     RB              A           
#> # … with 11 more variables: 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()
#> # A tibble: 4 × 6
#>   currentMatchupPeriod matchupId teamId abbrev totalPointsLive totalProjectedPointsLive
#>                  <int>     <int>  <int> <fct>            <dbl>                    <dbl>
#> 1                   17        33      1 AUS              108.                     107. 
#> 2                   17        33      2 BOS               92.9                     92.9
#> 3                   17        34      3 CHI              109.                     108. 
#> 4                   17        34      4 DEN              110.                     110.

Standings

league_standings()
#> # A tibble: 4 × 17
#>   seasonId scoringPeriodId teamId abbrev draftDayProjectedRa… currentProjecte… playoffSeed
#>      <int>           <int>  <int> <fct>                 <int>            <int>       <int>
#> 1     2021              19      1 AUS                       2                3           3
#> 2     2021              19      2 BOS                       4                4           4
#> 3     2021              19      3 CHI                       3                2           2
#> 4     2021              19      4 DEN                       1                1           1
#> # … with 10 more variables: rankCalculatedFinal <int>, gamesBack <dbl>, losses <int>,
#> #   percentage <dbl>, pointsAgainst <dbl>, pointsFor <dbl>, streakLength <int>,
#> #   streakType <chr>, ties <int>, wins <int>