I searched on the NY Times API website and I signed up into the website. I found the Books APIs and I chose the “Book Sellers History”. I retrieved info for the history to see the last few best sellers.
ex<-GET("https://api.nytimes.com/svc/books/v3/lists/best-sellers/history.json?api-key=mP5gHH5A5oHbVq6PHAd2pAdv0BlS6s12")
cat("The status returned is:", ex$status_code)
## The status returned is: 200
data <- fromJSON(rawToChar(ex$content))
names(data)
## [1] "status" "copyright" "num_results" "results"
# Constructing dataframe
df<-data.frame(data$results, stringsAsFactors = FALSE)
# Showing result
df %>%
select(title, description, author, publisher, price, isbns) %>%
rename("Title" = title, "Description" = description,"Author" = author, "Publisher" = publisher, "Price" = price, "ISBN" = isbns) %>%
kable
| Title | Description | Author | Publisher | Price | ISBN |
|---|---|---|---|---|---|
| “I GIVE YOU MY BODY …” | The author of the Outlander novels gives tips on writing sex scenes, drawing on examples from the books. | Diana Gabaldon | Dell | 0.00 | 0399178570 , 9780399178573 |
| “MOST BLESSED OF THE PATRIARCHS” | A character study that attempts to make sense of Jefferson’s contradictions. | Annette Gordon-Reed and Peter S Onuf | Liveright | 0.00 | 0871404427 , 9780871404428 |
| “YOU JUST NEED TO LOSE WEIGHT” | The co-host of the podcast “Maintenance Phase” examines myths about gaining and losing weight to dismantle anti-fat bias. | Aubrey Gordon | Beacon | 0.00 | 0807006475 , 0807006483 , 9780807006474, 9780807006481 |
| #ASKGARYVEE | The entrepreneur expands on subjects addressed on his Internet show, like marketing, management and social media. | Gary Vaynerchuk | HarperCollins | 0.00 | 0062273124 , 0062273132 , 9780062273123, 9780062273130 |
| #GIRLBOSS | An online fashion retailer traces her path to success. | Sophia Amoruso | Portfolio/Penguin/Putnam | 0.00 | 039916927X , 1591847931 , 9780399169274, 9781591847939 |
| #IMOMSOHARD | Kristin Hensley and Jen Smedley | HarperOne | 0.00 | 006285769X , 9780062857699 | |
| #NEVERAGAIN | Students from Marjory Stoneman Douglas High School describe the Valentine’s Day mass shooting and outline ways to prevent similar incidents. | David Hogg and Lauren Hogg | Random House | 0.00 | 198480183X , 9781984801838 |
| $100 STARTUP | How to build a profitable start up for $100 or less and be your own boss. | Chris Guillebeau | Crown Business | 23.00 | 0307951529 , 9780307951526 |
| $20 PER GALLON | Christopher Steiner | Grand Central | 0.00 | NULL | |
| ’57, Chicago | NA | Steve Monroe | NA | 0.00 | 0786867302 , 9780786867301 |
| ‘ROCK OF AGES:’‘ROLLING STONE’’ HISTORY OF ROCK AND ROLL’ | NA | GEOFFREY STOKES, KEN TUCKER’ ’ED WARD | NA | 0.00 | 0671630687 , 9780671630683 |
| ‘THE HIGH ROAD TO CHINA: GEORGE BOGLE, THE PANCHEN LAMA AND THE FIRST BRITISH EXPEDITION TO TIBET’ | NA | KATE TELTSCHER | NA | 0.00 | 0374217009 , 9780374217006 |
| ’TIL DEATH | Sharon Sala | Harlequin Mira | 0.00 | 0778314278 , 9780778314271 | |
| ’TIL DEATH DO US PART | A matchmaker in Victorian England turns to a crime novelist for help when she starts receiving a series of disturbingly personalized trinkets. | Amanda Quick | Berkley | 0.00 | 069819361X , 039917446X , 9780698193611, 9780399174469 |
| ’Til Faith Do Us Part: How Interfaith Marriage is Transforming America | NA | Naomi Schaefer Riley | NA | 0.00 | 0199873747 , 9780199873746 |
| ’TIS THE SEASON | Two classic holiday stories — “Under the Christmas Tree” (2009) and “Midnight Confessions” (2010) — plus the novella “Backward Glance” (1991). | Ron Carr | Harlequin Mira | 0.00 | 0778316645 , 9780778316640 |
| (RE)BORN IN THE USA | The soccer commentator describes how he embraced American popular culture while growing up in Liverpool. | Roger Bennett | Dey Street | 0.00 | 0062958690 , 0062958720 , 9780062958693, 9780062958723 |
| ——, THAT’S DELICIOUS | Action Bronson with Rachel Wharton | Abrams | 0.00 | 1419726552 , 9781419726552 | |
| …and the Horse He Rode In On: The People V. Kenneth Starr | NA | James Carville | NA | 0.00 | 0684857340 , 9780684857343 |
| .HACK G.U. , VOL. 5 | This series, set in the future, is about an online, multiplayer game run amok. This volume concludes the tale. | Hamazaki Tatsuya | TOKYOPOP | 10.99 | NULL |
Here, I chose “best sellers of book” data from New York APIs, and construct the data to read in the JSON into R. The data is transormed into R dataframe and the result is shown with data of Title, Description, Author, Publisher, Price, and ISBN.