How do I request and process JSON with python?

sa125 picture sa125 · May 12, 2010 · Viewed 130.5k times · Source

I am trying to send a GET request to a URL that I know returns data in the form of JSON using python.

I would like to know how to send this request to http://someurl/path/to/json, and how to parse it - preferably to a python dict.

Answer

webjunkie picture webjunkie · Sep 13, 2012

For anything with requests to URLs you might want to check out requests. For JSON in particular:

>>> import requests
>>> r = requests.get('https://github.com/timeline.json')
>>> r.json()
[{u'repository': {u'open_issues': 0, u'url': 'https://github.com/...