Issues with API key

Maximilian Zemsch

Hello,

I am trying to get access to TNG data using the API key in my user profile but it doesn't work. After running a few tests, it seems like the API request is not accepted. Here is the code I used in VS code to check if the API key works:

import requests

api_key = "KEY_HERE"
url = "https://www.tng-project.org/api/"

headers = {
    "Authorization": f"Token {api_key}"
}

response = requests.get(url, headers=headers)

print(f"Status Code: {response.status_code}")
print("Response:", response.json())

And this is the output:

Status Code: 403
Response: {'detail': 'Failed session auth (and no API-Key sent).'}

How can I overcome this problem? Thank you so much for helping me out!

Dylan Nelson
  • 5 Mar

The headers needs to have the right structure:

headers = {"api-key":api_key}
Maximilian Zemsch
  • 6 Mar

Thank you!

  • Page 1 of 1