The New York Times API

The New York Times web site provides a rich set of APIs, as described here: http://developer.nytimes.com/docs 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 R to read in the JSON data, and transform it to an R dataframe.

Accessing Top stories

api = "&api-key=d6063d0168754a29a97e8b29352a43a1"
url = "https://api.nytimes.com/svc/topstories/v2/home.json?sectionresponse_format"
data = fromJSON(paste0(url, api))

toparticles = as.data.frame(data$results)
top_subset = toparticles[, c("title", "abstract", "url", "section")]
kable(top_subset)
title abstract url section
Clinton, Trump, Halloween: Your Friday Evening Briefing Here’s what you need to know at the end of the day. http://www.nytimes.com/2016/10/28/briefing/clinton-trump-halloween.html Briefing
New Emails in Clinton Case Came From Anthony Weiner’s Computer The F.B.I. director, James B. Comey, told Congress that emails that surfaced in an unrelated case “appear to be pertinent to the investigation.” http://www.nytimes.com/2016/10/29/us/politics/fbi-hillary-clinton-email.html U.S.
‘This Changes Everything’: Donald Trump Exults as Hillary Clinton’s Team Scrambles The F.B.I. director’s disclosure of an investigation of new emails interrupted Mrs. Clinton’s momentum as Mr. Trump and other Republicans sought to take advantage. http://www.nytimes.com/2016/10/29/us/politics/donald-trump-hillary-clinton.html U.S.
Money Flows Down Ballot as Donald Trump Is Abandoned by Big Donors (Even Himself) Republican contributors shifted their focus to House and Senate races, filings showed, and Mr. Trump gave no cash to his campaign in the first three weeks of October. http://www.nytimes.com/2016/10/28/us/politics/money-flows-down-ballot-as-donald-trump-is-abandoned-by-big-donors-even-himself.html U.S.
The Road Trip That Changed Hillary Clinton’s Life Mrs. Clinton’s former landlord, now 97, recounts a road trip taken 42 years ago that offers a glimpse into the candidate the public seldom sees. http://www.nytimes.com/2016/10/29/us/politics/hillary-clinton-road-trip.html U.S.
Can the G.O.P. Survive a Trump Loss? We start by exploring the state of the Republican establishment. We end by examining the rebels trying to tear it down. http://www.nytimes.com/2016/10/28/podcasts/can-the-gop-survive-a-trump-loss.html Podcasts
Supreme Court to Rule in Transgender Access Case The question at issue involves a Virginia high school student and a federal directive that effectively expanded a Title IX definition of discrimination. http://www.nytimes.com/2016/10/29/us/politics/supreme-court-to-rule-in-transgender-access-case.html U.S.
‘I Live in a Lie’: Saudi Women Speak Up Nearly 6,000 women responded to a Times call-out about their lives in a private, patriarchal society, expressing their fears, frustrations and ambitions. http://www.nytimes.com/2016/10/29/world/middleeast/saudi-arabia-women.html World
World Series Game 3: Cubs and Indians Live Updates Wrigley Field hosts its first World Series game since 1945 as the Cubs and Indians play for a 2-1 series lead. http://www.nytimes.com/2016/10/28/sports/world-series-score-cubs-indians.html Sports
Bundy Brothers Acquitted in Takeover of Oregon Wildlife Refuge Ammon and Ryan Bundy and five of their followers faced federal felony charges stemming from the six-week takeover in January. http://www.nytimes.com/2016/10/28/us/bundy-brothers-acquitted-in-takeover-of-oregon-wildlife-refuge.html U.S.
After Oregon Verdict, Arguments About the Role of Race Outraged by the acquittal of protesters led by Ammon Bundy, some said on social media that nonwhite defendants would not have been treated as favorably. http://www.nytimes.com/2016/10/29/us/oregon-bundy-verdict-wildlife-refuge.html U.S.
No One Is Looking at This Headline You’re looking at Phil Heath, the six-time Mr. Olympia, who eats a lot of tilapia and works out in a strip-mall gym. http://www.nytimes.com/2016/10/29/sports/phil-heath-mr-olympia-bodybuilder.html Sports
Emails Again, This Time With Anthony Weiner James Comey’s failure to provide specifics about a new, potentially important development, less than two weeks before Election Day, is confounding. http://www.nytimes.com/2016/10/29/opinion/emails-again-this-time-with-anthony-weiner.html Opinion
Why Dakota Is the New Keystone The Standing Rock protest against a new oil pipeline is about safeguarding clean water and a safe climate for all. http://www.nytimes.com/2016/10/29/opinion/why-dakota-is-the-new-keystone.html Opinion
Why Israel Still Refuses to Choose It’s easier to leave Palestinians in limbo waiting for a ‘peace process’ that goes nowhere. http://www.nytimes.com/2016/10/30/opinion/sunday/why-israel-still-refuses-to-choose.html Opinion
How to Pick a Group Trip If you are planning a group trip, consider the schedule (lots of activities or plenty of free time) and whether you want to travel with others your age. http://www.nytimes.com/2016/10/30/travel/how-to-pick-a-group-trip.html Travel
Where should you live to escape climate change? Welcome to Boise! Bets for avoiding the worst droughts, wildfires and floods also include Portland, Me., San Francisco, Detroit and — surprise — New York City. http://www.nytimes.com/2016/10/20/science/9-cities-to-live-in-if-youre-worried-about-climate-change.html Science
Conan O’Brien Thinks Alien Life Exists. And That It Will Disappoint. His latest gig is as an executive producer of “People of Earth,” about a reporter who checks out a support group for alien abductees, on TBS. http://www.nytimes.com/2016/10/30/arts/television/conan-obrien-thinks-alien-life-exists-and-that-it-will-disappoint.html Arts
Why Couldn’t I Give My Child My Last Name? My grandfather’s family was all but wiped out in the Holocaust and I was the last person in my line to hold my family’s name. http://www.nytimes.com/2016/10/28/well/family/why-couldnt-i-give-my-child-my-last-name.html Well
The School of Wants and Needs — and Wood-Fired Showers A prep school that prepares students for entry into competitive colleges, but also teaches them how to raise livestock, grow vegetables and chop wood. http://www.nytimes.com/2016/10/29/your-money/california-prep-school-teaches-self-reliance.html Your Money
Philippine Mayor Accused of Drug Links by Duterte Is Killed by Police “If you are not guilty, why should you be afraid?” the mayor told The New York Times in August. http://www.nytimes.com/2016/10/29/world/asia/philippines-duterte-mayor-police.html World
Philippine President, Rodrigo Duterte, Says God Told Him to Quit Cursing President Rodrigo Duterte said the voice of the Almighty threatened to crash his plane if he didn’t stop swearing. http://www.nytimes.com/2016/10/29/world/asia/president-duterte-says-god-told-him-to-swear-off-the-curse-words.html World
U.S. Economy Grew 2.9% in 3rd Quarter, Picking Up the Pace This report and the monthly unemployment figures next week are the last snapshots of the overall economy before voters go to the polls on Nov. 8. http://www.nytimes.com/2016/10/29/business/economy/3rd-quarter-gdp.html Business Day
Pork Stew Gets a Chile Kick Coconut milk, garam masala and cayenne make for a luscious, fragrant pork stew. http://www.nytimes.com/2016/11/02/dining/pork-stew-chile-split-peas.html Food
Exxon Concedes It May Need to Declare Lower Value for Oil in Ground The company may have to concede that 3.6 billion barrels of oil-sand reserves and a billion barrels of other reserves are currently not profitable to produce. http://www.nytimes.com/2016/10/29/business/energy-environment/exxon-concedes-it-may-need-to-declare-lower-value-for-oil-in-ground.html Business Day
Tension Between Police and Standing Rock Protesters Reaches Boiling Point The tension had been building for months, with Native Americans who had camped out saying that the Dakota Access pipeline threatens the region’s water supply. http://www.nytimes.com/2016/10/29/us/dakota-access-pipeline-protest.html U.S.
Reviewing Toaster Ovens, and Selling Them, Too The Times is dipping a toe into the waters of “affiliate links.” It hopes to make money off products it writes about. It needs to tread carefully. http://www.nytimes.com/2016/10/29/public-editor/reviewing-toaster-ovens-and-selling-them-too.html Public Editor
The Cure for UTIs? It’s Not Cranberries A yearlong study of female nursing home patients who took high-dose cranberry capsules showed no reduction in urinary tract infections. http://www.nytimes.com/2016/10/28/health/cranberry-juice-uti.html Health
The Land at Stake Is in Australia, but the Focus Is on China A group led by an Australian mining magnate remains the sole bidder for vast swaths of grazing land, but the presence of a Chinese partner has drawn criticism. http://www.nytimes.com/2016/10/29/business/international/australia-kidman-china-land.html Business Day

Accessing Article Search API and searching for “big data”

url_search = "https://api.nytimes.com/svc/search/v2/articlesearch.json?q=big+data"
data_search <- fromJSON(paste0(url_search, api))
search_articles = as.data.frame(data_search$response$docs)
search_subset = search_articles[, c("snippet", "lead_paragraph", "web_url")]
kable(search_subset)
snippet lead_paragraph web_url
Data science offers a lot of promise in many fields, but for now, it seems wise to keep human beings in the loop. Data science offers a lot of promise in many fields, but for now, it seems wise to keep human beings in the loop. http://www.nytimes.com/2015/04/07/upshot/if-algorithms-know-all-how-much-should-humans-help.html
Donald J. Trump’s campaign is reminding women that there is still plenty to be frightened of. Donald J. Trump’s campaign is reminding women that there is still plenty to be frightened of. http://www.nytimes.com/2016/10/16/nyregion/misogyny-is-back-did-it-ever-go-away.html
A breakdown of the nonprofit institutions with the most degree- or certificate-seeking undergraduates. A breakdown of the nonprofit institutions with the most degree- or certificate-seeking undergraduates. http://www.nytimes.com/2007/07/29/education/edlife/29big.html
The largest college in the country? Miami Dade College has more than 45,000 students working toward graduation. But large enrollments don’t have to translate into brimming classrooms; Miami Dade (née Community) College has none of those 100-plus… The largest college in the country? Miami Dade College has more than 45,000 students working toward graduation. But large enrollments don’t have to translate into brimming classrooms; Miami Dade (née Community) College has none of those 100-plus freshmen lecture classes. Class size is one barometer of the academic experience; ratio of students to faculty is another. The colleges below are nonprofit institutions with the most degree- or certificate-seeking undergraduates, according to a College Board survey of 2006 enrollment. (Class size is for for-credit courses, and excludes labs, recitations or discussion subsections.) http://query.nytimes.com/gst/fullpage.html?res=9B0CE3D71039F93AA15754C0A9619C8B63
So what if it is only so-so as a TV show? On the Web, it just may have found a new life. Bigbrother2000.com, the official Web address of the CBS television show ‘’Big Brother,’’ was hailed last week as the top newcomer site in July in Media… So what if it is only so-so as a TV show? On the Web, it just may have found a new life. Bigbrother2000.com, the official Web address of the CBS television show ‘’Big Brother,’’ was hailed last week as the top newcomer site in July in Media Metrix’s monthly ratings. The company said that 4.25 million unique visitors logged onto the site during the month, where they were able to vote on which housemate should be dismissed or catch up on any episodes they may have missed. http://www.nytimes.com/2000/09/18/business/compressed-data-faltering-tv-show-hits-stride-on-web.html
Bruce Schneier, an expert in cryptography and security, has deep knowledge of the uses and abuses of data collection, but his viewpoints seem to subvert the democratic principles he supports. Bruce Schneier, an expert in cryptography and security, has deep knowledge of the uses and abuses of data collection, but his viewpoints seem to subvert the democratic principles he supports. http://www.nytimes.com/2015/03/17/business/dealbook/book-review-of-data-and-goliath-by-bruce-schneier.html
The death of the August vacation for psychotherapists underlines the cultural decline of the therapeutic profession in the life of New York. The death of the August vacation for psychotherapists underlines the cultural decline of the therapeutic profession in the life of New York. http://www.nytimes.com/2016/08/28/nyregion/a-rite-of-august-shrinks-away-for-some-new-yorkers.html
Big Data is the subject of a forthcoming glossy photo book, a smartphone application for personal data analysis and comparison, and an interactive version of the book for the iPad. The project is the brainchild of Rick Smolan, creator of the “Day in… NA http://bits.blogs.nytimes.com/2012/09/13/big-data-gets-its-own-photo-album/
Admissions conventional wisdom: elite institutions want geographic diversity, so to improve your chances, move to an underrepresented state. Indeed, for Harvard’s fall freshman class, the highest admittance rate was Wyoming’s, at 18 percent: 11… Admissions conventional wisdom: elite institutions want geographic diversity, so to improve your chances, move to an underrepresented state. Indeed, for Harvard’s fall freshman class, the highest admittance rate was Wyoming’s, at 18 percent: 11 applied, 2 got in. What does that tell you? Nothing really. In fact, New York, California and New Jersey are big feeder states to America’s selective colleges and universities. They have high numbers of applicants but also respectable admittance rates, as the chart below indicates. All things being equal, says William Fitzsimmons, Harvard’s dean of admissions, ‘’we do give a geographic tip to Boston and Cambridge and students from local communities.’’ So if you must move, move to Massachusetts. http://query.nytimes.com/gst/fullpage.html?res=9D03E5DF1F3DF931A35752C1A96E9C8B63
Start-ups are gathering data and analyzing it much faster than was possible even a couple of years ago, aiming to project economic trends from seemingly unconnected information. Start-ups are gathering data and analyzing it much faster than was possible even a couple of years ago, aiming to project economic trends from seemingly unconnected information. http://www.nytimes.com/2013/11/11/technology/gathering-more-data-faster-to-produce-more-up-to-date-information.html