Get data from from article search API related to the country of Cuba. You can change what is querried by renaming the “query” variable.

key<-"4055a9abca9d40368891f34acf3d6421"

url <- "http://api.nytimes.com/svc/search/v2/articlesearch.json?q="

query<-"Cuba"
url<-paste0(url,query,"&api-key=",key)
url
## [1] "http://api.nytimes.com/svc/search/v2/articlesearch.json?q=Cuba&api-key=4055a9abca9d40368891f34acf3d6421"
library(jsonlite)

rd<-jsonlite::fromJSON(url)

columns<-as.data.frame(rd$response)
names(columns)
##  [1] "meta.hits"              "meta.time"             
##  [3] "meta.offset"            "docs.web_url"          
##  [5] "docs.snippet"           "docs.lead_paragraph"   
##  [7] "docs.abstract"          "docs.print_page"       
##  [9] "docs.blog"              "docs.source"           
## [11] "docs.multimedia"        "docs.headline"         
## [13] "docs.keywords"          "docs.pub_date"         
## [15] "docs.document_type"     "docs.news_desk"        
## [17] "docs.section_name"      "docs.subsection_name"  
## [19] "docs.byline"            "docs.type_of_material" 
## [21] "docs._id"               "docs.word_count"       
## [23] "docs.slideshow_credits"
#Get data frame
zyx<-data.frame("Date"=columns$docs.pub_date,"Snippet"=columns$docs.snippet,"URL"=columns$docs.web_url,"Section"=columns$docs.section_name,"Abstract"=columns$docs.abstract)
head(zyx)
##                   Date
## 1 2016-10-24T23:39:37Z
## 2 2016-10-08T04:00:00Z
## 3 2016-10-26T16:54:14Z
## 4 2016-10-24T19:22:49Z
## 5 2016-10-14T16:23:03Z
## 6 2016-10-14T18:51:57Z
##                                                                                                                                             Snippet
## 1                               The museum is readying one of the largest exhibitions ever in the United States on Cuba<U+0092>s biodiversity and culture.
## 2                           Chris Wondolowski and Julian Green scored for the United States men in their first exhibition game in Cuba in 69 years.
## 3                       It is the first time the United States has not voted against the annual resolution condemning the half-century-old embargo.
## 4                                    Medicc, a nonprofit, writes that the embargo has <U+0093>stymied mutual work on critical health problems, like Zika.<U+0094>
## 5 In a sweeping directive, President Obama pressed forward in the face of lingering opposition in Congress to repealing the Cold War trade embargo.
## 6   In an effort to open a political dialogue, Tania Bruguera has released a video proposing that anyone should be able to run for any job in Cuba.
##                                                                                                                          URL
## 1 http://www.nytimes.com/2016/10/30/arts/design/cuba-in-all-its-natural-glory-at-the-american-museum-of-natural-history.html
## 2                  http://www.nytimes.com/2016/10/08/sports/soccer/united-states-men-win-in-cuba-in-a-tuneup-for-mexico.html
## 3                                          http://www.nytimes.com/2016/10/27/world/americas/united-nations-cuba-embargo.html
## 4                                                http://www.nytimes.com/2016/10/25/opinion/us-cuba-health-collaboration.html
## 5                                             http://www.nytimes.com/2016/10/15/world/americas/obama-cuba-trade-embargo.html
## 6                          http://www.nytimes.com/2016/10/15/arts/design/tania-bruguera-cuba-creative-time-summit-video.html
##   Section
## 1    Arts
## 2  Sports
## 3   World
## 4 Opinion
## 5   World
## 6    Arts
##                                                                                                                                                                                                                                                                                                                                   Abstract
## 1                                                                                                                                                                                                                                                                                                                                     <NA>
## 2                                                                                                                                                                                                                                                                                                                                     <NA>
## 3 United States abstains from United Nations General Assembly condemnation of 50-year-old US trade embargo against Cuba; is first time US delegation has not voted against resolution, which has been offered every year since 1991; abstention is latest signal from Obama administration about its intent to repair relations with Cuba.
## 4                                                                                                                                                                                                                                                                                                                                     <NA>
## 5                Pres Obama attempts to solidify his administration's historic restoration of ties with Cuba by issuing directive to lift Cold War trade embargo and end 50 years of secret plotting against Cuba's government; loosening of sanctions includes lifting of $100 limit on bringing Cuban cigars and rum into United States.
## 6                                                                                                                                                                                                                                                                                                                                     <NA>