tjfrahme tjfrahme - 1 year ago 614
Python Question

Pulling Data from App Annie API - Python

I need to pull some data from App Annie's API using Python. However I am unable to connect. I double checked my API key and the "documentation". Does anyone know how I can connect through their API? I keep getting a 401 unauthorized access error.

import json
import requests

url = ''
key = 'Authorization: bearer b7e26.........'

response = requests.get(url, key) #After running up to this I get 401

data = json.loads(response.json()) #data is a dictionary

Answer Source

You need to specify your api key in the HTTP header:

response = requests.get(url,
                        headers={'Authorization':'bearer b7e26.........'})
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download