ffl_api: Call the ESPN Fantasy API

View source: R/api.R

ffl_apiR Documentation

Call the ESPN Fantasy API

Description

Use httr::GET() to make a request to the ESPN API and return the parsed list from the JSON data. The function uses httr::RETRY(), so the call will repeat up to three times if there is a failure.

Usage

ffl_api(
  leagueId = ffl_id(),
  view = NULL,
  leagueHistory = FALSE,
  seasonId = 2023,
  scoringPeriodId = NULL,
  ...
)

Arguments

leagueId

Numeric league ID or ESPN fantasy page URL. Defaults to getOption("fflr.leagueId"). Function fails if no ID is found.

view

Character vector of specific API "views" which describe the data returned (e.g., "mRoster", "mSettings").

leagueHistory

logical; Should the leagueHistory version of the API be called? If TRUE, a list of results is returned, with one element for each historical year of the league.

seasonId

Integer year of NFL season. By default, the season is currently set to 2023. Use a recent year or set leagueHistory to TRUE to obtain all past data.

scoringPeriodId

Integer week of NFL season. By default, NULL will use the current week (see ffl_week()). Scoring periods are always one week in length, whereas matchups might be longer.

...

Additional queries passed to httr::GET(). Arguments are converted to a named list and passed to query alongside view.

Value

A single JSON string.

Examples

## Not run: 
ffl_api()

## End(Not run)

fflr documentation built on Sept. 14, 2023, 9:10 a.m.