Assigment

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 into an R DataFrame.

calling API and storing data

api_key <- "aFZgnziHlI2ihJtbCbFnBJnOqOHLHqgU"
baseurl <- "https://api.nytimes.com/svc/books/v3/lists.json"
list = list( `api-key`=api_key, list="hardcover-fiction")
response <- GET(baseurl, query=list)
db <- content(response)

Creating data frame

#Create a dataframe
  df = data.frame(Title = Title,Current = Current , Weeks = Weeks,
  Last_Week =  Last_Week, URL_AMAZON=URL_AMAZON)

Formatting

library(formattable)
## Warning: package 'formattable' was built under R version 4.0.3
as.datatable(formattable(df))
## Loading required namespace: DT