• How To
    • Win Your DFS League
    • Win Your Auction Draft
    • Win Your Snake Draft
    • Download Projections
    • Scrape Projections
    • Calculate Projections for Your League
    • Examine Accuracy of Projections
    • Identify Sleepers
    • Save Custom Settings
    • Use the API
  • Strategy
    • Fantasy Football is Like Stock Picking
    • Use Projections, Not Rankings
  • Projections
    • Our Projections
    • Who has the Best Projections?
    • Draft the Best Starting Lineup
    • Projections are More Accurate than Rankings
    • Points by Position Rank
    • Players’ Risk Levels
    • Value Over Replacement
    • Bid-Up-To Value
    • Player Value Gap
    • Gold Mining
    • Weekly Variability
    • Are Subscription Sources More Accurate?
  • Statistics
    • How To Learn R
    • R is Better than Excel
    • Do Stats Help in Fantasy Football?
    • Download/Run Our Scripts
    • ffanalytics R Package
  • Apps
    • Auction Draft Optimizer
    • Snake Draft Optimizer
    • Weekly Lineup Optimizer
    • Rankings/Projections for Your League
    • API
    • Other Tools
      • Stock Analysis
    • Error Logging
  • Testimonials
  • About the Site
    • About
    • Authors
      • Isaac Petersen
    • FAQ
    • FFA Insider
    • Privacy Policy
    • Terms of Service
  • Donate

Fantasy Football Analytics

API Instructions

5
  • by Val Pinskiy
  • in FFA Insider · How To · Projections · R · Tools
  • — 12 Jun, 2018

The Fantasy Football Analytics API allows developers to programmatically access our data in JSON format. Users must pay for a standalone subscription to obtain a unique API key granting access. To subscribe to the API, contact us at sales@fantasyfootballanalytics.net.

There are two API subscription types, “Basic” and “Premier”, both of which allow access to seasonal and weekly projections for previous seasons and to seasonal projections for the current season. Only the “Premier” subscription allows access to weekly projections for the current season. Both subscriptions also allow unrestricted access to ADP data for all seasons to date.

The API has two endpoints, “proj” and “adp”, which allow the user to get averaged projections and ADP data, respectively. API requests are expected to be made in the form of a simple HTTP GET, with users specifying various query parameters. Specifically, the optional query parameters for the “proj” endpoint are:

• pos: One of “qb” (default), “rb”, “wr”, “te”, “k”, “dst”, “dl”, “lb”, or “db”.
• season: A year between 2008 and the most recent NFL season (default), inclusive.
• week: An integer between 0 and 20, inclusive. The option week = 0 (default) corresponds to seasonal projections, whereas all other options correspond to weekly projections. The options week > 17 are used to designate playoff weeks. Weekly projections are not available for seasons prior to 2015.
• type: Scheme used to average individual projection sources; one of “average” (simple average; default), “robust” (robust average, which is resistant to outliers), or “weight” (weighted average, whereby the weights are based on historical projection accuracy).

The optional query parameters for the “adp” endpoint are:

• season: A year between 2015 and the most recent NFL season (default), inclusive.
• type: League type; either “std” (standard; default) or “ppr” (points-per-reception).

API calls can be made using a programming language of your choice. In particular, the example below demonstrates how to get weighted average projections for team defenses for the 2016 season using R. (Be sure to replace “YOUR_API_KEY” with your actual unique API key for the Authorization header.) Analogously, ADP data may be retrieved by changing the “endpoint” parameter to “adp” and setting the query parameters appropriately.

# query parameters
pos <- "dst"
season <- 2016
week <- 0
type <- "weight"

# construct API URL
protocol <- "https"
host <- "api.fantasyfootballanalytics.net/api"
endpoint <- "proj"
query.string <- paste0("?pos=", pos, "&season=", season, "&week=", week, "&type=", type)
URL <- paste0(protocol, "://", host, "/", endpoint, query.string)

# API key
api.key <- "YOUR_API_KEY"

# call API to get JSON
json <- httr::content(httr::GET(URL, httr::add_headers(Authorization = paste("Basic", api.key))),
type = "text")
# convert JSON to data frame
df <- jsonlite::fromJSON(json)

Please note that empty/null values are intentionally omitted from the returned JSON, following Google’s JSON style guide.

The attribute-value pairs in the returned projections object vary depending on the requested position: the object will contain passing statistics for QBs, receiving statistics for WRs and TEs, etc. See the scoring settings vignette in the ffanalytics package for further details. An example of the projections object for running backs in the 2019 season is provided below:
 
{
   "player": "Saquon Barkley", 
     "position": "RB", 
   "team": "NYG", 
   "rushAtt": 267.7298, 
   "rushYds": 1278.529, 
   "rushTds": 10.5618, 
   "rec": 87.4195, 
   "recYds": 695.697, 
   "recTds": 3.7501, 
   "fumbles": 2.15, 
   "twoPts": 1.34, 
   "rush40": 6.51, 
   "rec40": 2.05, 
   "games": 16, 
   "returnTds": 0, 
   "returnYds": 0
}

The attribute-value pairs in the ADP object do not vary with season or league type; an example of the ADP object for the 2019 season is provided below:

{
   "player": "Saquon Barkley", 
   "position": "RB", 
   "team": "NYG", 
   "adp": 1.3125
}

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to email a link to a friend (Opens in new window) Email

Like this:

Like Loading...

Related

Share

Tags: R

— Val Pinskiy

5 Comments

  1. Chris says:
    June 13, 2018 at 9:35 am

    how far back do the weekly projections go?

    Reply
    • Isaac Petersen says:
      June 13, 2018 at 9:42 am

      https://fantasyfootballanalytics.net/about-the-site/faq#historicalProjections

      Reply
  2. erik nelson says:
    December 14, 2018 at 5:28 pm

    Is the ADP data into the season? I’m looking for weekly updated rest-of-season rankings type data and ADP would work if people still are drafting during the season?

    Reply
  3. Jeffery Henderson says:
    July 11, 2019 at 1:52 pm

    I subscribed and do not see an API key when I click “my account”. could you help me locate this so I can get the past seasons projections data?

    Reply
    • Isaac Petersen says:
      July 11, 2019 at 6:29 pm

      You are subscribed to FFA Insider, not the API. To subscribe to the API, sign up for the Basic API or Premier API package, as described here:
      https://fantasyfootballanalytics.net/2018/06/fantasy-football-analytics-api.html

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Previous story Off Season Content
  • Next story Fantasy Football Analytics API
  • Tabs

    • Most Popular
    • Recent Posts
    • The ffanalytics R Package for Fantasy Football Data AnalysisJune 18, 2016
    • 2015 Fantasy Football Projections using OpenCPUMay 28, 2015
    • Win Your Fantasy Football Auction Draft: Determine the Optimal Players to Draft with this AppJune 14, 2013
    • Win Your Fantasy Football Snake Draft with this AppSeptember 1, 2013
    • Post-Combine Mock: Team Needs and TargetsMarch 10, 2025
    • Fantasy Football Weekly Cheat Sheet: Week 18 (2024)January 3, 2025
    • Fantasy Football Weekly Cheat Sheet: Week 17 (2024)December 26, 2024
    • Fantasy Football Weekly Cheat Sheet: Week 16 (2024)December 18, 2024
  • FFA Insider

    Logo
  • Categories

    • About the Authors
    • Articles
    • Auction Drafts
    • Draft Optimizer
    • FFA Insider
    • Gold Mining
    • How To
    • In the Media
    • Luck
    • Package
    • Projections
    • R
    • Risk
    • Theory
    • Tools
    • Trade Strategy
    • Uncategorized
    • Weekly
  • Facebook

  • Twitter

  • Our Partners

    R-bloggers

  • Support us building things... Even a cup of coffee ($1.99) helps us stay awake!

  • Subscribe to the Fantasy Football Analytics mailing list (no spam).
    Loading

        © Fantasy Football Analytics

        %d