The goal of this notebook is to utilize a particular API from the New York Times, to pull down information into rstudio. In this case I used the API for most popular articles.
library(httr)
library(jsonlite)
library(ggplot2)
**API KEY: XnPiUKStCqos1SlZbSRG1FGGM67aOLTp
Secret: U2gRcWAvt4eAmkse
res = GET("https://api.nytimes.com/svc/mostpopular/v2/viewed/30.json?api-key=XnPiUKStCqos1SlZbSRG1FGGM67aOLTp")
data = fromJSON(rawToChar(res$content))
most_viewed_30days <- data$results
ggplot(most_viewed_30days)+geom_bar(aes( x = section))
Now that we have our data, we can run analysis like the bar graph above, without having to clean the data to the degree that is required when data is scraped from the web instead using APIs.