jelmew.2531:

Hi all,

Surely there is someone here who knows how to use api keys using the request library in python. I’m trying to expend my own little database. For normal entries, this works (duh):
[spoiler]
def get_jsonparsed_data(url):
#Receive contect as url returned as object"
response=requests.get(url)
return response.json()
[/spoiler]

However, how would one do this using the api key? Googling gives me no clear answer yet, and I’m not that well traversed into the json world.

Greetings,
Jelmew

Eearslya.6309:

The simplest way is to just add the access_token parameter to your URL.
e.g. https://api.guildwars2.com/v2/account?access_token=ABCDEF-1234

jelmew.2531:

If I had known that it was that simple. Thanks a lot.

zeeZ.5713:

From Requests documentation:

def get_jsonparsed_data(url):
   # Receive contect as url returned as object"
   response=requests.get(url, headers={'Authorization': 'Bearer D34D8E3F-...'})
   return response.json()