Learn R Programming

fflr

The fflr package is used to query the ESPN Fantasy Football API. Get data on fantasy football league members, teams, and individual athletes.

This package has been tested with a narrow subset of possible league settings. If a function doesn’t work as intended, please file an issue on GitHub.

Installation

You can install the release version of fflr from CRAN:

install.packages("fflr")

The most recent development version can be installed from GitHub:

# install.packages("remotes")
remotes::install_github("k5cents/fflr")

Usage

library(fflr)
packageVersion("fflr")
#> [1] '2.2.3'

Data is only available for public leagues. See this help page on how to make a private league public

Functions require a unique leagueId, which can be found in any ESPN page URL.

Use ffl_id() to set a default fflr.leagueId option. Your .Rprofile file can set this option on startup.

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

The leagueId argument defaults to ffl_id() and can be omitted once set.

league_info()
#> # A tibble: 1 × 6
#>         id seasonId name             isPublic  size finalScoringPeriod
#>      <int>    <int> <chr>            <lgl>    <int>              <int>
#> 1 42654852     2023 FFLR Test League TRUE         4                 17
league_teams()
#> # A tibble: 4 × 6
#>   teamId abbrev name              logo                                            logoType memberId
#>    <int> <fct>  <chr>             <chr>                                           <chr>    <chr>   
#> 1      1 AUS    Austin Astronauts https://g.espncdn.com/lm-static/logo-packs/cor… VECTOR   {22DFE7…
#> 2      2 BOS    Boston Buzzards   https://g.espncdn.com/lm-static/logo-packs/cor… VECTOR   {22DFE7…
#> 3      3 CHI    Chicago Crowns    https://g.espncdn.com/lm-static/logo-packs/cor… VECTOR   {22DFE7…
#> 4      4 DEN    Denver Devils     https://g.espncdn.com/lm-static/logo-packs/cor… VECTOR   {22DFE7…

The scoringPeriodId argument can be used to get data from past weeks.

all_rost <- team_roster(scoringPeriodId = 1)
all_rost$CHI[, 5:13][-7]
#> # A tibble: 16 × 8
#>    lineupSlot playerId firstName lastName    proTeam position projectedScore actualScore
#>    <fct>         <int> <chr>     <chr>       <fct>   <fct>             <dbl>       <dbl>
#>  1 QB          4040715 Jalen     Hurts       Phi     QB                21.3        12.5 
#>  2 RB          3929630 Saquon    Barkley     NYG     RB                16.9         9.3 
#>  3 RB          4239996 Travis    Etienne Jr. Jax     RB                15.1        21.4 
#>  4 WR          4262921 Justin    Jefferson   Min     WR                20.1        24   
#>  5 WR          4569618 Garrett   Wilson      NYJ     WR                16.4        14.4 
#>  6 TE            15847 Travis    Kelce       KC      TE                 0           0   
#>  7 FLEX        4374302 Amon-Ra   St. Brown   Det     WR                16.7        19.1 
#>  8 D/ST         -16025 49ers     D/ST        SF      D/ST               7.78       14   
#>  9 K           3055899 Harrison  Butker      KC      K                  8.41        8   
#> 10 BE          4429795 Jahmyr    Gibbs       Det     RB                14.0         8   
#> 11 BE          3042519 Aaron     Jones       GB      RB                15.5        26.7 
#> 12 BE          3915511 Joe       Burrow      Cin     QB                19.8         3.18
#> 13 BE          2976499 Amari     Cooper      Cle     WR                13.6         6.7 
#> 14 BE          4697815 Rachaad   White       TB      RB                13.9         6.9 
#> 15 BE          3054850 Alvin     Kamara      NO      RB                 0           0   
#> 16 BE          4038941 Justin    Herbert     LAC     QB                16.9        20.9

There are included objects for NFL teams and players.

nfl_teams
#> # A tibble: 33 × 6
#>    proTeamId abbrev location   name       byeWeek conference
#>        <int> <fct>  <chr>      <chr>        <int> <chr>     
#>  1         0 FA     <NA>       Free Agent      NA <NA>      
#>  2         1 Atl    Atlanta    Falcons         14 NFC       
#>  3         2 Buf    Buffalo    Bills            7 AFC       
#>  4         3 Chi    Chicago    Bears           14 NFC       
#>  5         4 Cin    Cincinnati Bengals         10 AFC       
#>  6         5 Cle    Cleveland  Browns           9 AFC       
#>  7         6 Dal    Dallas     Cowboys          9 NFC       
#>  8         7 Den    Denver     Broncos          9 AFC       
#>  9         8 Det    Detroit    Lions            6 NFC       
#> 10         9 GB     Green Bay  Packers         14 NFC       
#> # ℹ 23 more rows

The fflr project is released with a Contributor Code of Conduct. By contributing, you agree to abide by its terms.

Copy Link

Version

Install

install.packages('fflr')

Monthly Downloads

62

Version

2.3.0

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Kiernan Nicholls

Last Published

May 3rd, 2024

Functions in fflr (2.3.0)

nfl_teams

2023 NFL Teams
player_acquire

Roster acquisition history
list_players

Find fantasy players
live_scoring

Live matchup scoreboard
roster_settings

League roster settings
roster_score

Sum of starting scores in a roster
pro_scores

Professional scores
nfl_schedule

2023 NFL Schedule
recent_activity

Roster moves
transaction_counter

League transactions
opponent_ranks

NFL team performance against positions
pro_schedule

Professional schedule
pro_events

Professional games
trade_settings

League trade settings
league_messages

Fantasy league teams
player_news

Player news
league_status

League status
player_outlook

Player outlooks
league_teams

Fantasy league teams
nfl_players

2023 NFL Players
player_info

Individual player information
team_abbrev

Convert team ID to abbreviation
schedule_settings

League schedule settings
team_roster

Fantasy team rosters
tidy_schedule

Fantasy match schedule
scoring_settings

League scoring settings
tidy_scores

Fantasy matchup scores
start_roster

Starting roster
stat_corrections

Stat corrections
all_players

All fantasy players (deprecated)
ffl_id

Get ESPN fantasy league ID
acquisition_settings

League waiver settings
best_roster

Sort the optimal fantasy roster
combine_history

Combine league history with current season
ffl_info

Get fantasy football information
draft_recap

Fantasy draft history
ffl_api

Call the ESPN Fantasy API
draft_settings

League draft settings
espn_games

List all fantasy games
league_size

League size
league_standings

League standings
league_info

League information
fflr-package

fflr: A package for collecting ESPN fantasy football data
league_members

Fantasy league teams
ffl_seasons

List past fantasy football seasons
league_name

League name
finance_settings

League finance settings
league_simulation

League standing simulation