loading required libraries
library(httr)
library(jsonlite)
GET request to the New York Times Article Search API
x <- fromJSON("https://api.nytimes.com/svc/search/v2/articlesearch.json?q=Nasa%20&sort=newest&api-key=UmvvGDXUnFcnoIKtwukkPGk06ZKBJMBf")
Flattens the resulting JSON object into a data frame
Nasa <- fromJSON("https://api.nytimes.com/svc/search/v2/articlesearch.json?q=Nasa%20&sort=newest&api-key=UmvvGDXUnFcnoIKtwukkPGk06ZKBJMBf", flatten = TRUE) %>% data.frame()
basic_info <- Nasa %>% 
  select(status, response.docs.source, response.docs.news_desk)
knitr::kable(basic_info)
status response.docs.source response.docs.news_desk
OK The New York Times Foreign
OK The New York Times NYTNow
OK The New York Times Graphics
OK The New York Times Politics
OK The New York Times Foreign
OK The New York Times Briefing
OK The New York Times NYTNow
OK The New York Times NYTNow
OK The New York Times NYTNow
OK The New York Times Styles