I am attempting to grab data from a sports API (documentation) that I recently signed up for. I have the Ocp-Apim-Subscription-Key but am unsure how to pass it to the GET request
My question is, how do I authenticate myself with these credentials / keys inside of R. If I run the following:
library(httr)
this_json <- GET("https://api.fantasydata.net/v3/nfl/scores/JSON/ScoresByWeek/2015REG/1")
It returns a 401 status, which wikipedia says is an unauthorized status. Are there functions in the httr library that I can use to authenicate myself?
According to the documentation you provided for the Fantasy Data API, you are required to pass the "Ocp-Apim-Subscription-Key" (whatever that is) as a header to your HTTP requestion. You can do this with httr
using add_headers()
this_json <- GET("https://api.<myapiprovider>.net/linktofeeds/JSON/etc",
add_headers("Ocp-Apim-Subscription-Key"= "<your-key-here>"))