Reputation: 57
So I have been trying to access this API, but I need to use an API key to access it. I have an API key, but I am unsure how to format everything and get the url transfered. My url looks like this--- https://api.sportsdata.io/v3/nfl/scores/json/Players
The sit I am using also left this message:
This is the documentation for SportsDataIO's NFL API. All of our API endpoints can be accessed via an HTTP GET request using your API key. The API key can be passed either as a query parameter or using the following HTTP request header.
Ocp-Apim-Subscription-Key: {key}
Not sure what this means, I am pretty new to data scraping.
If anyone can help, that would be great, thanks.
Upvotes: 2
Views: 10354
Reputation: 28630
Means you need to pass the api key through the headers:
import requests
api_key = 'put your api key here'
url = 'https://api.sportsdata.io/v3/nfl/scores/json/Players'
headers = {'Ocp-Apim-Subscription-Key': '{key}'.format(key=api_key)}
jsonData = requests.get(url, headers=headers).json()
Upvotes: 6