Assignment- Web APIs
@author:Joseph Simone
The New York Times web site provides a rich set of APIs, as described here: https://developer.nytimes.com/apis
You’ll need to start by signing up for an API key. Your task is to choose one of the New York Times APIs, construct an interface in Python to read in
the JSON data & transform it into a pandas DataFrame.
import requests
import json
from pprint import pprint
your_key = "FptvCLy8m9fKva5WGwlGQc2OJEjOJug5"
url = 'http://api.nytimes.com/svc/search/v2/articlesearch.json?q=new+york+times&page=2&sort=oldest&api-key='+ your_key
r = requests.get(url)
json_data = json.loads(r.text)
json_data = json.loads(r.text)
for key in json_data['response']['docs']:
print(key['headline']['main'])
ENGLAND.; Dullness of the Season--Thackeray's New Work--The Yacht--Ireland--The Queen's Visit to Scotland--The Cuban Question in England--A Balloon Accident, &c.
PHILADELPHIA.; Outrage on Gov. Jonnston--Another Fugitive Slave Case--The Christiana Tragedy.
LATEST INTELLIGENCE; Anti-Rent Convention.
BERLIN.; haracter of the City-Monument of Frederick the Great-Art in Berlin-Bruno Bauer-Watchmen-Theatres-Churches, & c.
CONNECTICUT.; Stafford Springs--New London--Appearnce and Antiquities of the Town, &c., &c.
Remains of Stephen Girard--The Telegraph Case--Coal, &c.
LATEST INTELLIGENCE; The Farmers' and Mechanica' Bank of New-Brunswick.
SKETCHES OF EUROPE.
LATEST INTELLIGENCE.; By Telegraph to The New-York Times. The And-Renters.
School Celebration at Albanr.