Authentication
How to authenticate your API requests with Statsnet.
View as MarkdownStatsnet verifies the authenticity of your API requests using your account’s unique API key. If you don’t include your key in an API request or use an incorrect or expired key, Statsnet will return an error.
You can access your API key by logging into your Statsnet account and visiting Developer Settings.
If you don’t have a Statsnet account, you can sign up in just a few minutes. Once you purchase a “Premium” plan or higher, you’ll be able to view your API key.
Code Examples
API request example
import requests
url = 'https://api.statsnet.co/v2/companies/search'
headers = {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
body = {'query': 'google'}
response = requests.post(url, json=body, headers=headers).json()
print(response)Error Handling
If the authorization header is missing or malformed, the API returns an HTTP response with status code 403 Forbidden and a JSON-encoded error:
{
"ok": false,
"error": {
"code": 403,
"message": "Forbidden"
}
}