You’ll need to start by signing up for an API key. Your task is to choose one of the New York Times APIs, construct an interface in R to read in the JSON data, and transform it to an R dataframe.
library(jsonlite)
library(httr)
Set API Key
apikey <- "N0kJIGXMAFAshBqvy9DQSEHG1IVArmH6"
Get the data
# make the url
url <- paste0("https://api.nytimes.com/svc/books/v3//lists/current/hardcover-fiction.json?api-key=",apikey)
fictionbooks <- GET(url)
Check response status
fictionbooks$status_code
## [1] 200
Convert to data frame
fictiondf <- fromJSON(url, flatten = TRUE)
fictiondf <- fictiondf$results
fictiondf <- fictiondf$books
DT::datatable(fictiondf)
The New York Times Book Review API is a weekly paper-magazine supplement to The New York Times in which current non-fiction and fiction books are reviewed. It is one of the most influential and widely read book review publications in the industry that lets users to get book reviews displayed by ISBN,name of author and title