Parse this JSON response From App Annie in Python -
i working request module within python grab fields within json response.
import json fn = 'download.json' data = json response = requests.get('http://api.appannie.com/v1/accounts/1000/apps/mysuperapp/sales?break_down=application+iap&start_date=2013-10-01&end_date=2013-10-02', \ auth=('username', 'password')) data = response.json() print(data)
this works in python, response following:
{'prev_page': none, 'currency': 'usd', 'next_page': none, 'sales_list': [{'revenue': {'ad': '0.00', 'iap': {'refunds': '0.00', 'sales': '0.00', 'promotions': '0.00'}, 'app': {'refunds': '0.00', 'updates': '0.00', 'downloads': '0.00', 'promotions': '0.00'}}, 'units': {'iap': {'refunds': 0, 'sales': 0, 'promotions': 0}, 'app': {'refunds': 0, 'updates': 0, 'downloads': 2000, 'promotions': 0}}, 'country': 'all', 'date': 'all'}], 'iap_sales': [], 'page_num': 1, 'code': 200, 'page_index': 0}
the question how parse downloads number within 'app' block - namely "2000" value?
you can use loads()
method of json
-
import json response = requests.get('http://api.appannie.com/v1/accounts/1000/apps/mysuperapp/sales?break_down=application+iap&start_date=2013-10-01&end_date=2013-10-02', auth=('username', 'password')) data = json.loads(response.json()) # data dictionary sales_list = data.get('sales_list') sales in sales_list: print sales['revenue']['app']
Comments
Post a Comment