pythoncurlestimote

Grabbing data from a curl request using python


I'm trying to use this curl request:

curl 'https://cloud.estimote.com/v2/analytics/visits?from=1448928000&to=1451606399&granularity=daily' -X GET -u YOUR_SDK_APP_ID:YOUR_SDK_APP_TOKEN

which outputs data in this form

{
"data": [{
"date": "2016-02-22",
"count": 183
}, {
"date": "2016-02-23",
"count": 162
}]
}

I want to use python to call the curl request. How do I do this?

Here's some documentation info: Documentation


Solution

  • import requests
    
    response = requests.get('https://cloud.estimote.com/v2/analytics/visits?from=1448928000&to=1451606399&granularity=daily', headers={'Authorization': 'access_token myToken'})
    

    You can then look at the response information, such as response.content, response.text, etc...

    Something like this, depending on the api/token http://docs.python-requests.org/en/master/