<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/api-instructions/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://fantasyfootballanalytics.net/2018/06/api-instructions.html"> R – Fantasy Football Analytics</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>The <a rel="nofollow" href="https://fantasyfootballanalytics.net/2018/06/fantasy-football-analytics-api.html" target="_blank">Fantasy Football Analytics API</a> 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. You must have an account on the Fantasy Football Analytics web app in order to subscribe to the API (simply click the “Register” tab in the navigation bar at <a rel="nofollow" href="http://apps.fantasyfootballanalytics.net/" target="_blank">http://apps.fantasyfootballanalytics.net/</a> to set up an account if you don’t already have one).</p>
<p>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.</p>
<p>To subscribe to the API, sign into the Fantasy Football Analytics web app, click the “Subscribe” tab in the navigation bar, and use the select box to choose your subscription type. After you enter your credit card information and click the “Subscribe” button, the “Subscribe” modal will disappear. If you have successfully subscribed to the API, your API key will appear at the bottom of the “My Account” modal.</p>
<p>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:</p>
<p>• pos: One of “qb” (default), “rb”, “wr”, “te”, “k”, “dst”, “dl”, “lb”, or “db”.<br>
• season: A year between 2008 and the most recent NFL season (default), inclusive.<br>
• 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.<br>
• 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).</p>
<p>The optional query parameters for the “adp” endpoint are:</p>
<p>• season: A year between 2015 and the most recent NFL season (default), inclusive.<br>
• type: League type; either “std” (standard; default) or “ppr” (points-per-reception).</p>
<p>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.</p>
<pre># query parameters
pos &lt;- &quot;dst&quot;
season &lt;- 2016
week &lt;- 0
type &lt;- &quot;weight&quot;

# construct API URL
protocol &lt;- &quot;http&quot;
host &lt;- &quot;api.fantasyfootballanalytics.net/api&quot;
endpoint &lt;- &quot;proj&quot;
query.string &lt;- paste0(&quot;?pos=&quot;, pos, &quot;&amp;season=&quot;, season, &quot;&amp;week=&quot;, week, &quot;&amp;type=&quot;, type)
URL &lt;- paste0(protocol, &quot;://&quot;, host, &quot;/&quot;, endpoint, query.string)

# API key
api.key &lt;- YOUR_API_KEY

# call API to get JSON
json &lt;- httr::content(httr::GET(URL, httr::add_headers(Authorization = paste(&quot;Basic&quot;, api.key))),
type = &quot;text&quot;)
# convert JSON to data frame
df &lt;- jsonlite::fromJSON(json)</pre>
<p>Please note that empty/null values are intentionally omitted from the returned JSON, following <a rel="nofollow" href="https://google.github.io/styleguide/jsoncstyleguide.xml" target="_blank">Google’s JSON style guide</a>.</p>
<p>The post <a rel="nofollow" href="https://fantasyfootballanalytics.net/2018/06/api-instructions.html" target="_blank">API Instructions</a> appeared first on <a rel="nofollow" href="https://fantasyfootballanalytics.net/" target="_blank">Fantasy Football Analytics</a>.</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://fantasyfootballanalytics.net/2018/06/api-instructions.html"> R – Fantasy Football Analytics</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/5budkRgoeWU" height="1"></a></div>