The New York Times web site provides a rich set of APIs, as described here: https://developer.nytimes.com/apis. 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 into an R DataFrame.


Went to the NY Times API Developer website and registered to access the API collection. Once registered, created new App in order to get the API keys for the book list API.


Did not clean up title column and left alone in case that is the actual title names in the NY Times book list. Some titles had number signs in front as well as other symbols.


library(jsonlite)
library(httr)
library(tidyr)
library(knitr)

r<- GET("https://api.nytimes.com/svc/books/v3/lists/best-sellers/history.json.json?api-key=8gkKGb1DOwEMoYb4TGlpZeUeORinGyam")
r$status_code
## [1] 200
data<- fromJSON(r$url)
df<-data.frame(data)
colnames(df)
##  [1] "status"                   "copyright"               
##  [3] "num_results"              "results.title"           
##  [5] "results.description"      "results.contributor"     
##  [7] "results.author"           "results.contributor_note"
##  [9] "results.price"            "results.age_group"       
## [11] "results.publisher"        "results.isbns"           
## [13] "results.ranks_history"    "results.reviews"
df2<- df[, c("results.title", "results.author","results.publisher")]
colnames(df2)=c("Title","Author","Publisher")  
kable(df2)
Title Author Publisher
“I GIVE YOU MY BODY …” Diana Gabaldon Dell
“MOST BLESSED OF THE PATRIARCHS” Annette Gordon-Reed and Peter S Onuf Liveright
#ASKGARYVEE Gary Vaynerchuk HarperCollins
#GIRLBOSS Sophia Amoruso Portfolio/Penguin/Putnam
#IMOMSOHARD Kristin Hensley and Jen Smedley HarperOne
#NEVERAGAIN David Hogg and Lauren Hogg Random House
$100 STARTUP Chris Guillebeau Crown Business
$20 PER GALLON Christopher Steiner Grand Central
’57, Chicago Steve Monroe NA
‘ROCK OF AGES:’‘ROLLING STONE’’ HISTORY OF ROCK AND ROLL’ GEOFFREY STOKES, KEN TUCKER’ ’ED WARD NA
‘THE HIGH ROAD TO CHINA: GEORGE BOGLE, THE PANCHEN LAMA AND THE FIRST BRITISH EXPEDITION TO TIBET’ KATE TELTSCHER NA
’TIL DEATH Sharon Sala Harlequin Mira
’TIL DEATH DO US PART Amanda Quick Berkley
’Til Faith Do Us Part: How Interfaith Marriage is Transforming America Naomi Schaefer Riley NA
’TIS THE SEASON Ron Carr Harlequin Mira
——, THAT’S DELICIOUS Action Bronson with Rachel Wharton Abrams
…and the Horse He Rode In On: The People V. Kenneth Starr James Carville NA
.HACK G.U. , VOL. 5 Hamazaki Tatsuya TOKYOPOP
1 Ragged Ridge Road David Adams Richards NA
1,000 PLACES TO SEE BEFORE YOU DIE Patricia Schultz Workman