#download required packages
suppressMessages(suppressWarnings(library(RCurl)))
suppressMessages(suppressWarnings(library(httr)))
suppressMessages(suppressWarnings(library(jsonlite)))
library(stringr)
url<-"http://api.nytimes.com/svc/search/v2/articlesearch.json?"
apikey <- "&api-key=4a0a4188c41a407786254f43dc1bf908"
q<-"q=new+york+times"
page<-"&page=20"
sort<-"&sort=oldest"
#red data from New York Time API
rawDf <- getURL(paste0(url,q,page,sort,apikey))
#store raw data into a data frame
df <- fromJSON(rawDf)
df <- data.frame(df)
df
## status
## 1 OK
## 2 OK
## 3 OK
## 4 OK
## 5 OK
## 6 OK
## 7 OK
## 8 OK
## 9 OK
## 10 OK
## copyright
## 1 Copyright (c) 2017 The New York Times Company. All Rights Reserved.
## 2 Copyright (c) 2017 The New York Times Company. All Rights Reserved.
## 3 Copyright (c) 2017 The New York Times Company. All Rights Reserved.
## 4 Copyright (c) 2017 The New York Times Company. All Rights Reserved.
## 5 Copyright (c) 2017 The New York Times Company. All Rights Reserved.
## 6 Copyright (c) 2017 The New York Times Company. All Rights Reserved.
## 7 Copyright (c) 2017 The New York Times Company. All Rights Reserved.
## 8 Copyright (c) 2017 The New York Times Company. All Rights Reserved.
## 9 Copyright (c) 2017 The New York Times Company. All Rights Reserved.
## 10 Copyright (c) 2017 The New York Times Company. All Rights Reserved.
## response.docs.web_url
## 1 https://query.nytimes.com/gst/abstract.html?res=9E07EFDD1E30E23AA15752C0A9679D946092D7CF
## 2 https://query.nytimes.com/gst/abstract.html?res=9E02E4DC1E30E23AA15752C0A9679D946092D7CF
## 3 https://query.nytimes.com/gst/abstract.html?res=9E07E7DC1E30E23AA15752C0A9679D946092D7CF
## 4 https://query.nytimes.com/gst/abstract.html?res=9E01E3DC1E30E23AA15752C0A9679D946092D7CF
## 5 https://query.nytimes.com/gst/abstract.html?res=9401E3DC1431E13BBC4B53DFB767838A649FDE
## 6 https://query.nytimes.com/gst/abstract.html?res=9802E3DC1431E13BBC4B53DFB767838A649FDE
## 7 https://query.nytimes.com/gst/abstract.html?res=9503E3DC1431E13BBC4B53DFB767838A649FDE
## 8 https://query.nytimes.com/gst/abstract.html?res=9B01E3DC1431E13BBC4B53DFB767838A649FDE
## 9 https://query.nytimes.com/gst/abstract.html?res=980DE3DC1431E13BBC4B53DFB767838A649FDE
## 10 https://query.nytimes.com/gst/abstract.html?res=9805E2DC1431E13BBC4C53DFB767838A649FDE
## response.docs.snippet
## 1 After many rumors--all founded on fact--many shrewd surmises, many premature bursts of congratulation or fury, a list of the new Cabinet, on which reliance can be placed, has at length come out. It is as follows: Hon. MALCOLM CAMERON, President of...
## 2 Henry W. Smith, a young man, was arrested yesterday while attempting to commit a robbery at the jewelry store of James E. Caldwell, in Chesnut street. This morning he was held to bail in $1,000 for a further hearing. Theodore C. Lewis's residence,...
## 3 The State Capitol has been more crowded to-day than it was yesterday. The weather has been very fine. The Plowing Match excited great interest. Numerous plows were entered, and the plowing represented various portions of the country. The ground se...
## 4 His claims to the Presidency
## 5
## 6 ITALIAN OPERA--'Norma' BROADWAY.--'French Spy' and 'Taming a Tartar.' BROUGHAM'S.--'A Wife for an Hour,' 'Catarina' and 'Kossuth's Kum.' NIBLO'S.--'Milliners,' 'Graziella' and 'Red Gnome White Warrior.' BURTON'S.--'As You Like It' and 'An Appeal ...
## 7 To the Editors of The New-York Daily Times: I beg leave to enclose you the following letter received from an attache in Government service traveling abroad: a gentleman of cool judgment, mature reflection and keen observation.
## 8 You are probably already aware of a rumor prevalent here to-day,that Chevalier Hulsemann had notified Mr. Webster of his instructions to withdraw upon the arrival and official reception of Kossuth. The Chevalier certainly had an interview with the...
## 9 The present is an exciting political campaign in Old Massachusetts, and promises to bring to the ballot-box by far the heaviest vote ever polled in the State, either at local or Presidential elections.
## 10 In pursuance of the policy of the Government to cultivate friendly relations with Japan, some Japanese, who were picked up at sea on a wreck, and brought into San Francisco, were sent home in a national vessel. At the same time, Commodore AuLICK w...
## response.docs.abstract response.docs.print_page
## 1 New ministry formed in 1
## 2 <NA> 2
## 3 Address before Penna Agr. Exhibition 2
## 4 His claims to the Presidency 3
## 5 <NA> 1
## 6 <NA> 2
## 7 Letter on "attache'" 2
## 8 <NA> 1
## 9 <NA> 4
## 10 Return of Japanese sailors 1
## response.docs.source response.docs.multimedia
## 1 The New York Times NULL
## 2 The New York Times NULL
## 3 The New York Times NULL
## 4 The New York Times NULL
## 5 The New York Times NULL
## 6 The New York Times NULL
## 7 The New York Times NULL
## 8 The New York Times NULL
## 9 The New York Times NULL
## 10 The New York Times NULL
## response.docs.headline.main
## 1 CANADA.; The New Cabinet-General Outline of Political Parties.
## 2 PHILADELPHIA.; Robbery-Arrests-The Hebrew Case-Weather,
## 3 LATEST INTELLIGENCE; Pennsylvania State Agricultural Fair. ADDRESS OF HON. ANDREW STEVENSON.
## 4 SPECIAL NOTICES.
## 5 LATEST INTELLIGENCE; Important from Washington--Intended Withdrawal of the Austrian Charge, &c.
## 6 NEW-YORK CITY; DESTRUCTIVE FIRE IN MAIDEN-LANE. FIRE IN THE EIGHTH WARD. AMUSEMENTS THIS EVENING. FIRE. FOUND DEAD IN A BATH. GOODS DAMAGED BY CROTON WATER. THE MODE OF CANVASSING. ATTEMPTED MURDER ALLEGED ABDUCTION. CUTTING WITH A KNIFE. MUTINY. LEUTZE'S WASHINGTON CROSSING THE DELAWARE. THE OPERA. MUSICAL SOIRESS OF MRS. E. G. BOSTWICK. NIBLO'S. ACCIDENT AT THE BATTERY POSTPONEMENT. COMMON COUNCIL. INSANITY AND ATTEMPTED SUICIDE. MORE OF THE SWEDISH SAILORS FOUND DROWNED. SUSPICION OF ROBBERIES. ELEVENTH WARD. RUN DOWN BY AN OMNIBUS.
## 7 KOSSUTH.; Letter from an American Attache. Alleged Misconduct of Kossuth and his Suite,
## 8 WASHINGTON.; Kossuth and the Proposed Withdrawal of Chevalier Hulseman.
## 9 MASSACHUSETTS.; Political Movements-Catherine Hayes' Concert--Death of Richard Walkly-Improvements.
## 10 WASHINGTON.; The United States and Japan--Salo of the Furniture of Sir Henry Bulwer-Col. BentonRecall of Mr. Rives-Appointments.
## response.docs.headline.kicker
## 1 <NA>
## 2 1
## 3 <NA>
## 4 <NA>
## 5 1
## 6 1
## 7 <NA>
## 8 1
## 9 1
## 10 <NA>
## response.docs.keywords
## 1 NA, 0, glocations, CANADA
## 2 NULL
## 3 NA, 0, persons, STEVENSON ANDREW
## 4 NA, 0, persons, CLAY, HENRY
## 5 NULL
## 6 NULL
## 7 NA, NA, 0, 0, persons, persons, KOSSUTH, LOUIS, HODGE, ANDREW CONSUL AT MARSEILLES
## 8 NULL
## 9 NULL
## 10 NA, 0, glocations, JAPAN
## response.docs.pub_date response.docs.document_type
## 1 1851-11-01T00:03:58Z article
## 2 1851-11-01T00:03:58Z article
## 3 1851-11-01T00:03:58Z article
## 4 1851-11-01T00:03:58Z article
## 5 1851-11-03T00:03:58Z article
## 6 1851-11-03T00:03:58Z article
## 7 1851-11-03T00:03:58Z article
## 8 1851-11-03T00:03:58Z article
## 9 1851-11-03T00:03:58Z article
## 10 1851-11-04T00:03:58Z article
## original
## 1 Correspondence of The New-York Daily Times
## 2 Correspondence of The New-York Daily Times
## 3 By Telegraph to The New-York Times
## 4 <NA>
## 5 By Telegraph to The New-York Times.Special Dispatch to The New-York Daily Times
## 6 <NA>
## 7 A. OAKEY HALL
## 8 Correspondence of The New-York Daily Times.k Daily Times
## 9 Correspondence of The New-York Daily Times
## 10 Correspondence of The New-York Daily Times
## response.docs.type_of_material response.docs._id
## 1 Front Page 4fbfd26f45c1498b0d005de8
## 2 Article 4fbfd28145c1498b0d006025
## 3 Article 4fbfd26f45c1498b0d005dde
## 4 Article 4fbfd25e45c1498b0d0058a2
## 5 Front Page 4fbfd25e45c1498b0d0057e1
## 6 Article 4fbfd26a45c1498b0d005ade
## 7 Article 4fbfd26a45c1498b0d005c33
## 8 Front Page 4fbfd28145c1498b0d00603b
## 9 Article 4fbfd26e45c1498b0d005c50
## 10 Front Page 4fbfd25e45c1498b0d0058bd
## response.docs.word_count response.docs.score response.meta.hits
## 1 1847 0.44998232 3741697
## 2 333 0.41612816 3741697
## 3 601 0.47523892 3741697
## 4 4250 0.01179158 3741697
## 5 68 0.37609285 3741697
## 6 2142 0.17786830 3741697
## 7 1793 0.01249789 3741697
## 8 191 0.35751778 3741697
## 9 490 0.41583400 3741697
## 10 862 0.41483206 3741697
## response.meta.offset response.meta.time
## 1 200 1068
## 2 200 1068
## 3 200 1068
## 4 200 1068
## 5 200 1068
## 6 200 1068
## 7 200 1068
## 8 200 1068
## 9 200 1068
## 10 200 1068