library(httr)
URL <- "https://api.nytimes.com/svc/search/v2/articlesearch.json"
params <- list()
params["api-key"] <- Sys.getenv("NYT_API_KEY")
params["q"] <- "North Korea"
params["fl"] <- "headline,snippet,abstract"
response <- GET(URL, query=params)
content <- content(response)
content$response$docs %>%
sapply(function(x) {x$headline$print_headline}) %>%
unlist()
## [1] "An Open Letter of Love to Kim Jong-un"
## [2] "Trump, Kim and the Possibility of War"
## [3] "Slouching Toward War"
## [4] "How to Talk to North Korea"
## [5] "In the Debate Over North Korea, Does Anyone Care What South Korea Thinks?"
## [6] "트럼프의 겁나는 대북한 전략"
## [7] "왜 나는 북한에 갔는가"
## [8] "Trump Leaves New South Korean Leader in Bind"
## [9] "북한 안에서, 그리고 전쟁의 북 소리를 느끼며"
## [10] "Pyongyang’s Cyberpower"