I will connect to the NYT books API and extract information about the best-sellers. Please note: I have created an R script that takes user input and for date and desired genre of book and outputs the list of bestsellers. However, R Markdown files cannot take user input so I simply demonstrate basic functionality here. I encourage you to view the R Script as well.
library(httr)
## Warning: package 'httr' was built under R version 3.6.3
library(purrr)
library(data.table)
##
## Attaching package: 'data.table'
## The following object is masked from 'package:purrr':
##
## transpose
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:data.table':
##
## between, first, last
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
my_url <- 'https://api.nytimes.com/svc/books/v3/lists/current/hardcover-fiction.json?api-key=UqP0yywZyQnj7yWwzolaZwWN0x8CaNcn'
r <- GET(my_url)
books <- content(r, "parse")
##Taking the parsed data we navigate to the books and then turn
##all books into data tables before binding them into one.
b <- books[['results']][['books']]
b <- lapply(b, function(x){x[1:23]})
b <- map(b, as.data.table)
df <- do.call(bind_rows, b)
df
## rank rank_last_week weeks_on_list asterisk dagger primary_isbn10
## 1: 1 2 81 0 0 0735219095
## 2: 2 0 1 0 0 1538748142
## 3: 3 4 9 0 0 1250209765
## 4: 4 1 2 0 0 0805096604
## 5: 5 0 1 0 0 0593128400
## 6: 6 0 1 0 0 0440001552
## 7: 7 11 2 0 0 1982137444
## 8: 8 9 4 0 0 0316420336
## 9: 9 3 2 0 0 0593083083
## 10: 10 6 2 0 0 006294150X
## 11: 11 12 42 0 0 1250301696
## 12: 12 7 3 0 0 1635574048
## 13: 13 8 3 0 0 0525538232
## 14: 14 0 23 0 0 0399562486
## 15: 15 13 26 0 0 0062963678
## primary_isbn13 publisher
## 1: 9780735219090 Putnam
## 2: 9781538748145 Grand Central
## 3: 9781250209764 Flatiron
## 4: 9780805096606 Holt
## 5: 9780593128404 Del Rey
## 6: 9780440001553 Ace
## 7: 9781982137441 Atria
## 8: 9780316420334 Little, Brown
## 9: 9780593083086 Putnam
## 10: 9780062941503 Morrow
## 11: 9781250301697 Celadon
## 12: 9781635574043 Bloomsbury
## 13: 9780525538233 Putnam
## 14: 9780399562488 Pamela Dorman/Viking
## 15: 9780062963673 Harper
## description
## 1: In a quiet town on the North Carolina coast in 1969, a young woman who survived alone in the marsh becomes a murder suspect.
## 2: When a girl goes missing, a private investigator’s feral childhood becomes an asset in the search.
## 3: A bookseller flees Mexico for the United States with her son while pursued by the head of a drug cartel.
## 4: The third book in the Wolf Hall trilogy. After Anne Boleyn’s execution, Thomas Cromwell’s enemies assemble.
## 5: The Resistance goes on a new adventure as word of the re-emergence of Emperor Palpatine is sent across the galaxy.
## 6: The 12th book in the Mercy Thompson series. The car mechanic who has the ability to turn into a coyote takes on a deadly foe.
## 7: A Manhattan lawyer finds herself confronting a vision she had when elements of it come to life on schedule.
## 8: The 12th book in the Michael Bennett series. A serial-killing spree might impact national security.
## 9: The 17th book of the NUMA Files series. The NUMA squad teams with British MI5 to stop arms dealers from stealing ancient relics.
## 10: A woman re-evaluates the relationship she had at age 15 with her 42-year-old English teacher 17 years ago.
## 11: Theo Faber looks into the mystery of a famous painter who stops speaking after shooting her husband.
## 12: Passion arises between Bryce Quinlan and Hunt Athalar as they seek to avenge the deaths of Bryce’s friends.
## 13: The 20th book in the Joe Pickett series. A grizzly bear attack and an attempted assassination of a local judge baffle the Wyoming game warden.
## 14: In Depression-era Kentucky, five women refuse to be cowed by men or convention as they deliver books.
## 15: A sibling relationship is impacted when the family goes from poverty to wealth and back again over the course of many decades.
## price title author
## 1: 0 WHERE THE CRAWDADS SING Delia Owens
## 2: 0 THE BOY FROM THE WOODS Harlan Coben
## 3: 0 AMERICAN DIRT Jeanine Cummins
## 4: 0 THE MIRROR & THE LIGHT Hilary Mantel
## 5: 0 STAR WARS: THE RISE OF SKYWALKER Rae Carson
## 6: 0 SMOKE BITTEN Patricia Briggs
## 7: 0 IN FIVE YEARS Rebecca Serle
## 8: 0 BLINDSIDE James Patterson and James O Born
## 9: 0 JOURNEY OF THE PHARAOHS Clive Cussler and Graham Brown
## 10: 0 MY DARK VANESSA Kate Elizabeth Russell
## 11: 0 THE SILENT PATIENT Alex Michaelides
## 12: 0 HOUSE OF EARTH AND BLOOD Sarah J Maas
## 13: 0 LONG RANGE CJ Box
## 14: 0 THE GIVER OF STARS Jojo Moyes
## 15: 0 THE DUTCH HOUSE Ann Patchett
## contributor contributor_note
## 1: by Delia Owens
## 2: by Harlan Coben
## 3: by Jeanine Cummins
## 4: by Hilary Mantel
## 5: by Rae Carson
## 6: by Patricia Briggs
## 7: by Rebecca Serle
## 8: by James Patterson and James O. Born
## 9: by Clive Cussler and Graham Brown
## 10: by Kate Elizabeth Russell
## 11: by Alex Michaelides
## 12: by Sarah J. Maas
## 13: by C.J. Box
## 14: by Jojo Moyes
## 15: by Ann Patchett
## book_image book_image_width
## 1: https://s1.nyt.com/du/books/images/9780735219090.jpg 328
## 2: https://s1.nyt.com/du/books/images/9781538748145.jpg 331
## 3: https://s1.nyt.com/du/books/images/9781250209764.jpg 326
## 4: https://s1.nyt.com/du/books/images/9780805096606.jpg 329
## 5: https://s1.nyt.com/du/books/images/9780593128404.jpg 329
## 6: https://s1.nyt.com/du/books/images/9780440001553.jpg 331
## 7: https://s1.nyt.com/du/books/images/9781982137441.jpg 326
## 8: https://s1.nyt.com/du/books/images/9780316420334.jpg 319
## 9: https://s1.nyt.com/du/books/images/9780593083086.jpg 335
## 10: https://s1.nyt.com/du/books/images/9780062941503.jpg 329
## 11: https://s1.nyt.com/du/books/images/9781250301697.jpg 326
## 12: https://s1.nyt.com/du/books/images/9781635574043.jpg 329
## 13: https://s1.nyt.com/du/books/images/9780525538233.jpg 331
## 14: https://s1.nyt.com/du/books/images/9780399562501.jpg 328
## 15: https://s1.nyt.com/du/books/images/9780062963673.jpg 328
## book_image_height
## 1: 495
## 2: 500
## 3: 495
## 4: 500
## 5: 500
## 6: 500
## 7: 500
## 8: 495
## 9: 500
## 10: 500
## 11: 495
## 12: 500
## 13: 500
## 14: 495
## 15: 495
## amazon_product_url
## 1: https://www.amazon.com/Where-Crawdads-Sing-Delia-Owens/dp/0735219095?tag=NYTBS-20
## 2: https://www.amazon.com/dp/1538748142?tag=NYTBSREV-20&tag=NYTBS-20
## 3: https://www.amazon.com/American-Dirt-Oprahs-Book-Club/dp/1250209765?tag=NYTBS-20
## 4: https://www.amazon.com/dp/0805096604?tag=NYTBSREV-20&tag=NYTBS-20
## 5: https://www.amazon.com/dp/0593128400?tag=NYTBSREV-20&tag=NYTBS-20
## 6: https://www.amazon.com/dp/0440001552?tag=NYTBSREV-20&tag=NYTBS-20
## 7: https://www.amazon.com/dp/1982137444?tag=NYTBSREV-20&tag=NYTBS-20
## 8: https://www.amazon.com/Blindside-Michael-Bennett-James-Patterson/dp/0316420336?tag=NYTBS-20
## 9: https://www.amazon.com/dp/0593083083?tag=NYTBSREV-20&tag=NYTBS-20
## 10: https://www.amazon.com/dp/006294150X?tag=NYTBSREV-20&tag=NYTBS-20
## 11: https://www.amazon.com/Silent-Patient-Alex-Michaelides/dp/1250301696?tag=NYTBS-20
## 12: https://www.amazon.com/dp/1635574048?tag=NYTBSREV-20&tag=NYTBS-20
## 13: https://www.amazon.com/dp/0525538232?tag=NYTBSREV-20&tag=NYTBS-20
## 14: https://www.amazon.com/Giver-Stars-Novel-Jojo-Moyes/dp/0399562486?tag=NYTBS-20
## 15: https://www.amazon.com/Dutch-House-Novel-Ann-Patchett/dp/0062963678?tag=NYTBS-20
## age_group
## 1:
## 2:
## 3:
## 4:
## 5:
## 6:
## 7:
## 8:
## 9:
## 10:
## 11:
## 12:
## 13:
## 14:
## 15:
## book_review_link
## 1:
## 2:
## 3: https://www.nytimes.com/2020/01/17/books/review-american-dirt-jeanine-cummins.html
## 4: https://www.nytimes.com/2020/02/25/books/review/mirror-light-hilary-mantel.html
## 5:
## 6:
## 7:
## 8:
## 9:
## 10: https://www.nytimes.com/2020/03/06/books/review/my-dark-vanessa-kate-elizabeth-russell.html
## 11:
## 12:
## 13:
## 14:
## 15: https://www.nytimes.com/2019/09/21/books/review-dutch-house-ann-patchett.html
## first_chapter_link sunday_review_link article_chapter_link
## 1:
## 2:
## 3:
## 4:
## 5:
## 6:
## 7:
## 8:
## 9:
## 10:
## 11:
## 12:
## 13:
## 14:
## 15: