Created
July 9, 2014 10:45
-
-
Save mattandrews/e9e54e792cad9fe8589e to your computer and use it in GitHub Desktop.
Guardian Content API python example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
def get_content(): | |
api_url = 'http://content.guardianapis.com/' | |
payload = { | |
'api-key': 'YOUR-API-KEY-HERE', | |
'page-size': 10, | |
'show-editors-picks': 'true', | |
'show-elements': 'image', | |
'show-fields': 'all' | |
} | |
response = requests.get(api_url, params=payload) | |
data = response.json() # convert json to python-readable format | |
return data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment