Fetching data from New York Times APIs

The New York Times web site provides a rich set of APIs, as described here.

  1. Sign up for at least one API key
  2. Choose an API to search and construct an interface in R to read in the JSON data
  3. Transform the data into an R

Getting Proper Library if it’s not install then install it

if (!require('stringr')) install.packages('stringr')
if (!require('dplyr')) install.packages('dplyr')
if (!require('jsonlite')) install.packages('jsonlite')

Importing and Searching and Prepping Key

Using the Top Stories API to look for stories in the Technology section of the NY Times. Setting up my key for importing articles.

key <- "&api-key=Yrr0djuV78dAkxirOY3EwIkbXJbrXtDM" # API key

Retrieve

# add url and text required for api request
url <- "https://api.nytimes.com/svc/topstories/v2/technology.json"
url <- paste0(url, "?")
# make api request using link provided by NY Times
feed <- fromJSON(paste0(url, key))

Setting up Data Frame with relevant article

article <- feed$results

article <- article %>% 
    filter(section == "technology") %>% 
    select(title, abstract, byline, published_date)

Conclusion

knitr::kable(article)
title abstract byline published_date
The Latest Covid Misinformation Star Says He Invented the Vaccines Dr. Robert Malone says he helped invent mRNA vaccines and has been wronged for decades. Now he’s spreading unfounded claims about the vaccines and the virus. By Davey Alba 2022-04-03T05:00:17-04:00
Amazon Workers on Staten Island Vote to Unionize in Landmark Win for Labor Despite heavy lobbying by the company, workers at the facility voted by a wide margin for a union. It was seen as a rebuke of the company’s treatment of its employees. By Karen Weise and Noam Scheiber 2022-04-01T12:34:54-04:00
House committee opens investigation into Amazon’s labor practices. A tornado that hit a delivery station in Illinois last year will be a focus of the inquiry. By Karen Weise 2022-04-01T09:00:08-04:00
Union Trails in Amazon Vote in Alabama, With Challenges Pending The count was much closer than another unionization vote taken at the facility last year. By Noam Scheiber 2022-03-31T17:23:36-04:00
Hugs to Boring Don’t underestimate the tech that makes your eyes glaze over. It holds us all up. By Shira Ovide 2022-03-31T13:01:32-04:00
Want a Value-Priced Gadget? Good Luck. More Americans than ever are buying fancy phones and laptops. Will it last? By Shira Ovide 2022-03-30T12:17:33-04:00
Spring Is Here! Here’s How to Spot the Seasonal Scams. Along with the annual wave of tax-related phishing attempts, fake Ukrainian war-relief charities are flooding the internet. By J. D. Biersdorfer 2022-03-30T09:00:12-04:00
Turing Award Won by Programmer Who Paved Way for Supercomputers In the 1970s, Jack Dongarra created code and concepts that allowed software to work easily with the world’s most powerful computing machines. By Cade Metz 2022-03-30T05:00:33-04:00
How War in Ukraine Roiled Facebook and Instagram The rules over what war content is permitted on Facebook and Instagram keep changing, causing internal confusion. By Ryan Mac, Mike Isaac and Sheera Frenkel 2022-03-30T05:00:19-04:00
State attorneys general ask Snap and TikTok to give parents more control over apps. Concerns that popular social media platforms can expose children to posts that are sexualized, hurt their body image or are violent have escalated in recent years. By David McCabe 2022-03-29T18:25:56-04:00
Pro-Russia Sentiment on Indian Twitter Draws Scrutiny While India and Russia have long had close ties, researchers say there are signs that social media posts parroting Kremlin talking points may not be legitimate. By Kate Conger and Suhasini Raj 2022-03-29T13:13:13-04:00
Apple and the Streaming Mirage Apple’s “CODA” won the Oscar for best picture. Cool. But what happens when Big Tech stops throwing money around? By Shira Ovide 2022-03-29T12:59:51-04:00
How Robots Can Assist Students With Disabilities New tools use artificial intelligence to assist students with autism and dyslexia and address accessibility for those who are blind or deaf. By Alina Tugend 2022-03-29T05:00:23-04:00
Uber Close to Deal for Partnership With San Francisco Taxi Outfit Passengers could soon use the Uber app to order taxis in a deal similar to one recently announced in New York City. By Kellen Browning 2022-03-28T20:34:07-04:00
A New City, Built Upon Data, Takes Shape in South Korea Fifty-four families volunteered to share data on everything from sleeping habits to trash volume to help developers make a city from scratch in Busan. By David Belcher 2022-03-28T05:00:19-04:00
When Nokia Pulled Out of Russia, a Vast Surveillance System Remained The Finnish company played a key role in enabling Russia’s cyberspying, documents show, raising questions of corporate responsibility. By Adam Satariano, Paul Mozur and Aaron Krolik 2022-03-28T03:00:13-04:00
The True Crime-Obsessed Philanthropists Paying to Catch Killers When the police can’t afford to solve cold cases using DNA databases, deep-pocketed donors can. By Kashmir Hill 2022-03-27T03:00:17-04:00