R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

library(httr)
## Warning: package 'httr' was built under R version 4.3.3
library(jsonlite)
## Warning: package 'jsonlite' was built under R version 4.3.3
api_key <- Sys.getenv("NY_TIMES_API_KEY")

url <- paste0("https://api.nytimes.com/svc/books/v3/lists/current/hardcover-fiction.json?api-key=", api_key)
response <- GET(url)
status_code(response)
## [1] 200
content <- content(response, "text")
json_data <- fromJSON(content, flatten = TRUE)
#str(json_data)

df <- as.data.frame(json_data$results$books)

print("Json to Data Frame")
## [1] "Json to Data Frame"
print(df)
##    rank rank_last_week weeks_on_list asterisk dagger primary_isbn10
## 1     1              0             1        0      0     031656379X
## 2     2              1             4        0      0     0593449592
## 3     3              4            37        0      0     1250178630
## 4     4              3             4        0      0     0374602638
## 5     5              6            50        0      0     1649374178
## 6     6              2             2        0      0     1250355664
## 7     7              0             1        0      0     0593817028
## 8     8              5             2        0      0     1538770385
## 9     9              0             1        0      0     0593725336
## 10   10              8             3        0      0     031640389X
## 11   11             10             6        0      0     0593798600
## 12   12             11            16        0      0     0593418913
## 13   13             14             6        0      0     0593446097
## 14   14              0            16        0      0     0385550367
## 15   15             12            14        0      0     0593798872
##    primary_isbn13                 publisher
## 1   9780316563796             Little, Brown
## 2   9780593449592              Random House
## 3   9781250178633              St. Martin's
## 4   9780374602635 Farrar, Straus and Giroux
## 5   9781649374172                 Red Tower
## 6   9781250355669                   Bramble
## 7   9780593817025                       Ace
## 8   9781538770382             Grand Central
## 9   9780593725337                Ballantine
## 10  9780316403894             Little, Brown
## 11  9780593798607                     Crown
## 12  9780593418918                 Riverhead
## 13  9780593446096              Random House
## 14  9780385550369                 Doubleday
## 15  9780593798874                     Crown
##                                                                                                                                          description
## 1                           The sixth book in the Ballard and Bosch series. Bosch’s daughter, Maddie, becomes a new volunteer on the cold case unit.
## 2                 A man in search of the father he never knew encounters a single mom and rumors circulate of the nearby appearance of a white deer.
## 3                                   In 1965, a nursing student follows her brother to serve during the Vietnam War and returns to a divided America.
## 4                                     After the passing of their father, seemingly different brothers engage in relationships and seek ways to cope.
## 5                  The second book in the Empyrean series. Violet Sorrengail’s next round of training might require her to betray the man she loves.
## 6                               Astraea must decide whether to sneak in as a substitute in the trials that will determine the safety of her kingdom.
## 7                                                   Aspeth Honori joins the Royal Artifactual Guild and partners with a minotaur to save her family.
## 8                                                     The 28th book in the Kay Scarpetta Series. Scarpetta investigates the death of a former lover.
## 9                                              A woman on a solo holiday retreat encounters complications with a small town’s main store proprietor.
## 10                                                                               An act of heroism by an Illinois pub owner may lead to his undoing.
## 11                                                 Passengers on a short and seemingly unremarkable flight learn how and when they are going to die.
## 12                            When a 13-year-old girl disappears from an Adirondack summer camp in 1975, secrets kept by the Van Laar family emerge.
## 13                        As a murder casts a pall on a town in Maine, Lucy Barton, Olive Kitteridge and Bob Burgess share stories and seek meaning.
## 14 A reimagining of “Adventures of Huckleberry Finn” shines a different light on Mark Twain's classic, revealing new facets of the character of Jim.
## 15                     Questions arise when a boy saves the daughter of a wealthy family amid a string of disappearances in a Missouri town in 1975.
##    price                      title                          author
## 1   0.00                THE WAITING                Michael Connelly
## 2   0.00          COUNTING MIRACLES                 Nicholas Sparks
## 3   0.00                  THE WOMEN                  Kristin Hannah
## 4   0.00                 INTERMEZZO                    Sally Rooney
## 5   0.00                 IRON FLAME                  Rebecca Yarros
## 6   0.00        THE STARS ARE DYING              Chloe C. Peñaranda
## 7   0.00           BULL MOON RISING                        Ru Dixon
## 8   0.00           IDENTITY UNKNOWN               Patricia Cornwell
## 9   0.00           A CHRISTMAS DUET                 Debbie Macomber
## 10  0.00            LIES HE TOLD ME James Patterson and David Ellis
## 11  0.00            HERE ONE MOMENT                  Liane Moriarty
## 12  0.00       THE GOD OF THE WOODS                       Liz Moore
## 13  0.00         TELL ME EVERYTHING                Elizabeth Strout
## 14  0.00                      JAMES                Percival Everett
## 15  0.00 ALL THE COLORS OF THE DARK                  Chris Whitaker
##                           contributor contributor_note
## 1                 by Michael Connelly                 
## 2                  by Nicholas Sparks                 
## 3                   by Kristin Hannah                 
## 4                     by Sally Rooney                 
## 5                   by Rebecca Yarros                 
## 6               by Chloe C. Peñaranda                 
## 7                       by Ruby Dixon                 
## 8                by Patricia Cornwell                 
## 9                  by Debbie Macomber                 
## 10 by James Patterson and David Ellis                 
## 11                  by Liane Moriarty                 
## 12                       by Liz Moore                 
## 13                by Elizabeth Strout                 
## 14                by Percival Everett                 
## 15                  by Chris Whitaker                 
##                                                              book_image
## 1  https://storage.googleapis.com/du-prd/books/images/9780316563796.jpg
## 2  https://storage.googleapis.com/du-prd/books/images/9780593449592.jpg
## 3  https://storage.googleapis.com/du-prd/books/images/9781250178633.jpg
## 4  https://storage.googleapis.com/du-prd/books/images/9780374602635.jpg
## 5  https://storage.googleapis.com/du-prd/books/images/9781649374172.jpg
## 6  https://storage.googleapis.com/du-prd/books/images/9781250355669.jpg
## 7  https://storage.googleapis.com/du-prd/books/images/9780593817025.jpg
## 8  https://storage.googleapis.com/du-prd/books/images/9781538770382.jpg
## 9  https://storage.googleapis.com/du-prd/books/images/9780593725337.jpg
## 10 https://storage.googleapis.com/du-prd/books/images/9780316403894.jpg
## 11 https://storage.googleapis.com/du-prd/books/images/9780593798607.jpg
## 12 https://storage.googleapis.com/du-prd/books/images/9780593418918.jpg
## 13 https://storage.googleapis.com/du-prd/books/images/9780593446096.jpg
## 14 https://storage.googleapis.com/du-prd/books/images/9780385550369.jpg
## 15 https://storage.googleapis.com/du-prd/books/images/9780593798874.jpg
##    book_image_width book_image_height
## 1               323               500
## 2               330               500
## 3               333               500
## 4               326               500
## 5               309               500
## 6               341               500
## 7               356               500
## 8               331               500
## 9               340               500
## 10              331               500
## 11              329               500
## 12              331               500
## 13              331               500
## 14              333               500
## 15              328               500
##                                           amazon_product_url age_group
## 1  https://www.amazon.com/dp/031656379X?tag=thenewyorktim-20          
## 2  https://www.amazon.com/dp/0593449592?tag=thenewyorktim-20          
## 3  https://www.amazon.com/dp/1250178630?tag=thenewyorktim-20          
## 4  https://www.amazon.com/dp/0374602638?tag=thenewyorktim-20          
## 5  https://www.amazon.com/dp/1649374178?tag=thenewyorktim-20          
## 6  https://www.amazon.com/dp/1250355664?tag=thenewyorktim-20          
## 7  https://www.amazon.com/dp/0593817028?tag=thenewyorktim-20          
## 8  https://www.amazon.com/dp/1538770385?tag=thenewyorktim-20          
## 9  https://www.amazon.com/dp/0593725336?tag=thenewyorktim-20          
## 10 https://www.amazon.com/dp/031640389X?tag=thenewyorktim-20          
## 11 https://www.amazon.com/dp/0593798600?tag=thenewyorktim-20          
## 12 https://www.amazon.com/dp/0593418913?tag=thenewyorktim-20          
## 13 https://www.amazon.com/dp/0593446097?tag=thenewyorktim-20          
## 14 https://www.amazon.com/dp/0385550367?tag=thenewyorktim-20          
## 15 https://www.amazon.com/dp/0593798872?tag=thenewyorktim-20          
##    book_review_link first_chapter_link sunday_review_link article_chapter_link
## 1                                                                             
## 2                                                                             
## 3                                                                             
## 4                                                                             
## 5                                                                             
## 6                                                                             
## 7                                                                             
## 8                                                                             
## 9                                                                             
## 10                                                                            
## 11                                                                            
## 12                                                                            
## 13                                                                            
## 14                                                                            
## 15                                                                            
##                                                                                                         isbns
## 1                             031656379X, 0316580791, 0316563811, 9780316563796, 9780316580793, 9780316563819
## 2                                                        0593449592, 0593449606, 9780593449592, 9780593449608
## 3                                                        1250178630, 1250178657, 9781250178633, 9781250178657
## 4                                                        0374602638, 0374602646, 9780374602635, 9780374602642
## 5                                                        1649374178, 1705085083, 9781649374172, 9781705085080
## 6                                                        1250355664, 1250370442, 9781250355669, 9781250370440
## 7                                                                                   0593817028, 9780593817025
## 8                             1538770385, 1538770431, 1538770415, 9781538770382, 9781538770436, 9781538770412
## 9                                                    , 0593725336, 0593725344, , 9780593725337, 9780593725344
## 10                                                       031640389X, 031640439X, 9780316403894, 9780316404396
## 11                            0593798600, 0593798619, 0593948262, 9780593798607, 9780593798614, 9780593948262
## 12                            0593418913, 059341893X, 0593867793, 9780593418918, 9780593418932, 9780593867792
## 13                                                       0593446097, 0593446100, 9780593446096, 9780593446102
## 14                                                       0385550367, 0385550375, 9780385550369, 9780385550376
## 15 0593798872, 0593798880, 0593949005, 0593943333, 9780593798874, 9780593798881, 9780593949009, 9780593943335
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 buy_links
## 1                               Amazon, Apple Books, Barnes and Noble, Books-A-Million, Bookshop.org, https://www.amazon.com/dp/031656379X?tag=thenewyorktim-20, https://goto.applebooks.apple/9780316563796?at=10lIEQ, https://www.anrdoezrs.net/click-7990613-11819508?url=https%3A%2F%2Fwww.barnesandnoble.com%2Fw%2F%3Fean%3D9780316563796, https://www.anrdoezrs.net/click-7990613-35140?url=https%3A%2F%2Fwww.booksamillion.com%2Fp%2FTHE%2BWAITING%2FMichael%2BConnelly%2F9780316563796, https://bookshop.org/a/3546/9780316563796
## 2                          Amazon, Apple Books, Barnes and Noble, Books-A-Million, Bookshop.org, https://www.amazon.com/dp/0593449592?tag=thenewyorktim-20, https://goto.applebooks.apple/9780593449592?at=10lIEQ, https://www.anrdoezrs.net/click-7990613-11819508?url=https%3A%2F%2Fwww.barnesandnoble.com%2Fw%2F%3Fean%3D9780593449592, https://www.anrdoezrs.net/click-7990613-35140?url=https%3A%2F%2Fwww.booksamillion.com%2Fp%2FCOUNTING%2BMIRACLES%2FNicholas%2BSparks%2F9780593449592, https://bookshop.org/a/3546/9780593449592
## 3                                   Amazon, Apple Books, Barnes and Noble, Books-A-Million, Bookshop.org, https://www.amazon.com/dp/1250178630?tag=thenewyorktim-20, https://goto.applebooks.apple/9781250178633?at=10lIEQ, https://www.anrdoezrs.net/click-7990613-11819508?url=https%3A%2F%2Fwww.barnesandnoble.com%2Fw%2F%3Fean%3D9781250178633, https://www.anrdoezrs.net/click-7990613-35140?url=https%3A%2F%2Fwww.booksamillion.com%2Fp%2FTHE%2BWOMEN%2FKristin%2BHannah%2F9781250178633, https://bookshop.org/a/3546/9781250178633
## 4                                      Amazon, Apple Books, Barnes and Noble, Books-A-Million, Bookshop.org, https://www.amazon.com/dp/0374602638?tag=thenewyorktim-20, https://goto.applebooks.apple/9780374602635?at=10lIEQ, https://www.anrdoezrs.net/click-7990613-11819508?url=https%3A%2F%2Fwww.barnesandnoble.com%2Fw%2F%3Fean%3D9780374602635, https://www.anrdoezrs.net/click-7990613-35140?url=https%3A%2F%2Fwww.booksamillion.com%2Fp%2FINTERMEZZO%2FSally%2BRooney%2F9780374602635, https://bookshop.org/a/3546/9780374602635
## 5                                  Amazon, Apple Books, Barnes and Noble, Books-A-Million, Bookshop.org, https://www.amazon.com/dp/1649374178?tag=thenewyorktim-20, https://goto.applebooks.apple/9781649374172?at=10lIEQ, https://www.anrdoezrs.net/click-7990613-11819508?url=https%3A%2F%2Fwww.barnesandnoble.com%2Fw%2F%3Fean%3D9781649374172, https://www.anrdoezrs.net/click-7990613-35140?url=https%3A%2F%2Fwww.booksamillion.com%2Fp%2FIRON%2BFLAME%2FRebecca%2BYarros%2F9781649374172, https://bookshop.org/a/3546/9781649374172
## 6      Amazon, Apple Books, Barnes and Noble, Books-A-Million, Bookshop.org, https://www.amazon.com/dp/1250355664?tag=thenewyorktim-20, https://goto.applebooks.apple/9781250355669?at=10lIEQ, https://www.anrdoezrs.net/click-7990613-11819508?url=https%3A%2F%2Fwww.barnesandnoble.com%2Fw%2F%3Fean%3D9781250355669, https://www.anrdoezrs.net/click-7990613-35140?url=https%3A%2F%2Fwww.booksamillion.com%2Fp%2FTHE%2BSTARS%2BARE%2BDYING%2FChloe%2BC.%2BPe%25C3%25B1aranda%2F9781250355669, https://bookshop.org/a/3546/9781250355669
## 7                                Amazon, Apple Books, Barnes and Noble, Books-A-Million, Bookshop.org, https://www.amazon.com/dp/0593817028?tag=thenewyorktim-20, https://goto.applebooks.apple/9780593817025?at=10lIEQ, https://www.anrdoezrs.net/click-7990613-11819508?url=https%3A%2F%2Fwww.barnesandnoble.com%2Fw%2F%3Fean%3D9780593817025, https://www.anrdoezrs.net/click-7990613-35140?url=https%3A%2F%2Fwww.booksamillion.com%2Fp%2FBULL%2BMOON%2BRISING%2FRu%2BDixon%2F9780593817025, https://bookshop.org/a/3546/9780593817025
## 8                         Amazon, Apple Books, Barnes and Noble, Books-A-Million, Bookshop.org, https://www.amazon.com/dp/1538770385?tag=thenewyorktim-20, https://goto.applebooks.apple/9781538770382?at=10lIEQ, https://www.anrdoezrs.net/click-7990613-11819508?url=https%3A%2F%2Fwww.barnesandnoble.com%2Fw%2F%3Fean%3D9781538770382, https://www.anrdoezrs.net/click-7990613-35140?url=https%3A%2F%2Fwww.booksamillion.com%2Fp%2FIDENTITY%2BUNKNOWN%2FPatricia%2BCornwell%2F9781538770382, https://bookshop.org/a/3546/9781538770382
## 9                         Amazon, Apple Books, Barnes and Noble, Books-A-Million, Bookshop.org, https://www.amazon.com/dp/0593725336?tag=thenewyorktim-20, https://goto.applebooks.apple/9780593725337?at=10lIEQ, https://www.anrdoezrs.net/click-7990613-11819508?url=https%3A%2F%2Fwww.barnesandnoble.com%2Fw%2F%3Fean%3D9780593725337, https://www.anrdoezrs.net/click-7990613-35140?url=https%3A%2F%2Fwww.booksamillion.com%2Fp%2FA%2BCHRISTMAS%2BDUET%2FDebbie%2BMacomber%2F9780593725337, https://bookshop.org/a/3546/9780593725337
## 10 Amazon, Apple Books, Barnes and Noble, Books-A-Million, Bookshop.org, https://www.amazon.com/dp/031640389X?tag=thenewyorktim-20, https://goto.applebooks.apple/9780316403894?at=10lIEQ, https://www.anrdoezrs.net/click-7990613-11819508?url=https%3A%2F%2Fwww.barnesandnoble.com%2Fw%2F%3Fean%3D9780316403894, https://www.anrdoezrs.net/click-7990613-35140?url=https%3A%2F%2Fwww.booksamillion.com%2Fp%2FLIES%2BHE%2BTOLD%2BME%2FJames%2BPatterson%2Band%2BDavid%2BEllis%2F9780316403894, https://bookshop.org/a/3546/9780316403894
## 11                          Amazon, Apple Books, Barnes and Noble, Books-A-Million, Bookshop.org, https://www.amazon.com/dp/0593798600?tag=thenewyorktim-20, https://goto.applebooks.apple/9780593798607?at=10lIEQ, https://www.anrdoezrs.net/click-7990613-11819508?url=https%3A%2F%2Fwww.barnesandnoble.com%2Fw%2F%3Fean%3D9780593798607, https://www.anrdoezrs.net/click-7990613-35140?url=https%3A%2F%2Fwww.booksamillion.com%2Fp%2FHERE%2BONE%2BMOMENT%2FLiane%2BMoriarty%2F9780593798607, https://bookshop.org/a/3546/9780593798607
## 12                      Amazon, Apple Books, Barnes and Noble, Books-A-Million, Bookshop.org, https://www.amazon.com/dp/0593418913?tag=thenewyorktim-20, https://goto.applebooks.apple/9780593418918?at=10lIEQ, https://www.anrdoezrs.net/click-7990613-11819508?url=https%3A%2F%2Fwww.barnesandnoble.com%2Fw%2F%3Fean%3D9780593418918, https://www.anrdoezrs.net/click-7990613-35140?url=https%3A%2F%2Fwww.booksamillion.com%2Fp%2FTHE%2BGOD%2BOF%2BTHE%2BWOODS%2FLiz%2BMoore%2F9780593418918, https://bookshop.org/a/3546/9780593418918
## 13                     Amazon, Apple Books, Barnes and Noble, Books-A-Million, Bookshop.org, https://www.amazon.com/dp/0593446097?tag=thenewyorktim-20, https://goto.applebooks.apple/9780593446096?at=10lIEQ, https://www.anrdoezrs.net/click-7990613-11819508?url=https%3A%2F%2Fwww.barnesandnoble.com%2Fw%2F%3Fean%3D9780593446096, https://www.anrdoezrs.net/click-7990613-35140?url=https%3A%2F%2Fwww.booksamillion.com%2Fp%2FTELL%2BME%2BEVERYTHING%2FElizabeth%2BStrout%2F9780593446096, https://bookshop.org/a/3546/9780593446096
## 14                                      Amazon, Apple Books, Barnes and Noble, Books-A-Million, Bookshop.org, https://www.amazon.com/dp/0385550367?tag=thenewyorktim-20, https://goto.applebooks.apple/9780385550369?at=10lIEQ, https://www.anrdoezrs.net/click-7990613-11819508?url=https%3A%2F%2Fwww.barnesandnoble.com%2Fw%2F%3Fean%3D9780385550369, https://www.anrdoezrs.net/click-7990613-35140?url=https%3A%2F%2Fwww.booksamillion.com%2Fp%2FJAMES%2FPercival%2BEverett%2F9780385550369, https://bookshop.org/a/3546/9780385550369
## 15         Amazon, Apple Books, Barnes and Noble, Books-A-Million, Bookshop.org, https://www.amazon.com/dp/0593798872?tag=thenewyorktim-20, https://goto.applebooks.apple/9780593798874?at=10lIEQ, https://www.anrdoezrs.net/click-7990613-11819508?url=https%3A%2F%2Fwww.barnesandnoble.com%2Fw%2F%3Fean%3D9780593798874, https://www.anrdoezrs.net/click-7990613-35140?url=https%3A%2F%2Fwww.booksamillion.com%2Fp%2FALL%2BTHE%2BCOLORS%2BOF%2BTHE%2BDARK%2FChris%2BWhitaker%2F9780593798874, https://bookshop.org/a/3546/9780593798874
##                                           book_uri
## 1  nyt://book/02a9b619-657e-5ed7-a70e-fd8fb9eba9e6
## 2  nyt://book/974caeee-6bf0-524c-809c-29bfdd99d65f
## 3  nyt://book/9ce735af-71cf-5ff3-a367-43ee07e3fdd7
## 4  nyt://book/a3bcdd05-312a-566b-90ec-df50e894bce6
## 5  nyt://book/d3c570c9-3c3a-5c8b-a740-85ea5e92bfc9
## 6  nyt://book/00d75ee8-72b6-5ca0-a903-a770b5b6901c
## 7  nyt://book/7767b28f-4f7d-5125-aea9-1ae57ba46fd3
## 8  nyt://book/3ebef85f-33bf-57c4-b9c8-86120e2ef599
## 9  nyt://book/ffad7c1d-8665-507b-be11-76f962d3419c
## 10 nyt://book/679690c4-c012-5a67-9cb5-1a1b219085ac
## 11 nyt://book/7e99e658-bd91-5488-a007-2bd74a8ef613
## 12 nyt://book/76d129f6-ab9c-591c-b25e-9a2758250c07
## 13 nyt://book/3f5b9449-8053-58fe-b24d-67c77f14d384
## 14 nyt://book/5788b098-426a-5f2c-a318-475692df69ee
## 15 nyt://book/4a3574a1-cb25-5910-a11e-f97ffb3508bd