Load Library
suppressWarnings(library(RJSONIO))
Read URL with provided key for NYT Books API. Pulling top 5 list of allotted books by published date.
url = "https://api.nytimes.com/svc/books/v3/lists/overview.json?published-date=2017-10-01"
urlkey = paste0(url,'&api-key=','a7649f031d6e4c68a095858d15734692')
booksurl = fromJSON(content = urlkey)
convert data to dataframe
booksubcat = booksurl$results$lists
booksdf = as.data.frame(do.call(rbind,booksubcat[[1]]$books))
finaldf = subset(booksdf,select = c("title","author","description","publisher","age_group","price","rank"))
Final results by Published Dates
print(finaldf)
## title author
## 1 A COLUMN OF FIRE Ken Follett
## 2 IT Stephen King
## 3 THE GIRL WHO TAKES AN EYE FOR AN EYE David Lagercrantz
## 4 ENIGMA Catherine Coulter
## 5 THE ROMANOV RANSOM Clive Cussler and Robin Burcell
## description
## 1 The lovers Ned Willard and Margery Fitzgerald find themselves on opposite sides of a conflict between English Catholics and Protestants while Queen Elizabeth fights to maintain her throne.
## 2 The collective clown phobias of seven teenagers are rekindled in their adult lives by the terrifying title character. Originally published in 1986.
## 3 Lisbeth Salander teams up with an investigative journalist to uncover the secrets of her childhood. A continuation of Stieg Larsson's Millennium series.
## 4 Agents Savich and Sherlock team up with Cam Wittier and Jack Cabot to capture an international criminal and solve a John Doe case.
## 5 Sam and Remi Fargo search for two missing filmmakers in North Africa and uncover a group seeking to create the Fourth Reich.
## publisher age_group price rank
## 1 Viking 0 1
## 2 Scribner 0 2
## 3 Knopf 0 3
## 4 Gallery Books 0 4
## 5 Putnam 0 5
print(paste("The top 5 best books in October were: ",paste(unlist(finaldf$title),collapse = ", ")))
## [1] "The top 5 best books in October were: A COLUMN OF FIRE, IT, THE GIRL WHO TAKES AN EYE FOR AN EYE, ENIGMA, THE ROMANOV RANSOM"