I have decided to read in data from the Books API. In particular, I will pull the most recent bestsellers list for fiction (both print and ebook).
link <- 'https://api.nytimes.com/svc/books/v3/lists/current/combined-print-and-e-book-fiction.json?api-key=EtTLK80hGeDW3v0ipV1Rmr5tBL7V1rSk'
json_list <- fromJSON(link)
current_fictions <- as_tibble(json_list$results$books)
glimpse(current_fictions)
## Rows: 15
## Columns: 26
## $ rank <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
## $ rank_last_week <int> 1, 0, 3, 2, 4, 0, 0, 0, 7, 6, 8, 9, 10, 5, 13
## $ weeks_on_list <int> 2, 1, 72, 2, 47, 13, 1, 1, 42, 3, 8, 184, 4, 2, 70
## $ asterisk <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
## $ dagger <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
## $ primary_isbn10 <chr> "1668001225", "1984818554", "1501110365", "038554…
## $ primary_isbn13 <chr> "9781668001226", "9781984818553", "9781501110368"…
## $ publisher <chr> "Atria", "Delacorte", "Atria", "Doubleday", "Gran…
## $ description <chr> "In the sequel to “It Ends With Us,” Lily deals w…
## $ price <chr> "0.00", "0.00", "0.00", "0.00", "0.00", "0.00", "…
## $ title <chr> "IT STARTS WITH US", "NO PLAN B", "IT ENDS WITH U…
## $ author <chr> "Colleen Hoover", "Lee Child and Andrew Child", "…
## $ contributor <chr> "by Colleen Hoover", "by Lee Child and Andrew Chi…
## $ contributor_note <chr> "", "", "", "", "", "", "", "", "", "", "", "", "…
## $ book_image <chr> "https://storage.googleapis.com/du-prd/books/imag…
## $ book_image_width <int> 322, 330, 319, 329, 324, 326, 328, 338, 128, 331,…
## $ book_image_height <int> 500, 500, 495, 500, 500, 495, 500, 500, 198, 500,…
## $ amazon_product_url <chr> "https://www.amazon.com/dp/1668001225?tag=NYTBSRE…
## $ age_group <chr> "", "", "", "", "", "", "", "", "", "", "", "", "…
## $ book_review_link <chr> "", "", "", "", "", "", "", "", "", "", "", "", "…
## $ first_chapter_link <chr> "", "", "", "", "", "", "", "", "", "", "", "", "…
## $ sunday_review_link <chr> "", "", "", "", "", "", "", "", "", "", "", "", "…
## $ article_chapter_link <chr> "", "", "", "", "", "", "", "", "", "", "", "", "…
## $ isbns <list> [<data.frame[3 x 2]>], [<data.frame[4 x 2]>], [<d…
## $ buy_links <list> [<data.frame[6 x 2]>], [<data.frame[6 x 2]>], [<d…
## $ book_uri <chr> "nyt://book/3aa85e47-4df9-53ef-9957-a77753d3502c"…
It is no use cleaning the data because this bestsellers list is updated weekly. A column devoid of any information this week might have relevant information next week, so it can’t be dropped. However, it makes sense to create a subset of the main dataframe so that only the essential information (title, author, and description) is readily available for quick perusal.
basic_info <- current_fictions %>%
select(title, author, description)
knitr::kable(basic_info)
| title | author | description |
|---|---|---|
| IT STARTS WITH US | Colleen Hoover | In the sequel to “It Ends With Us,” Lily deals with her jealous ex-husband as she reconnects with her first boyfriend. |
| NO PLAN B | Lee Child and Andrew Child | The 27th book in the Jack Reacher series. Reacher goes after a killer but is unaware of the bigger implications. |
| IT ENDS WITH US | Colleen Hoover | A battered wife raised in a violent home attempts to halt the cycle of abuse. |
| THE BOYS FROM BILOXI | John Grisham | Two childhood friends follow in their fathers’ footsteps, which puts them on opposite sides of the law. |
| VERITY | Colleen Hoover | Lowen Ashleigh is hired by the husband of an injured writer to complete her popular series and uncovers a horrifying truth. |
| FIRE AND BLOOD | George R.R. Martin | Set 300 years before the events of “A Game of Thrones,” this is the first volume of the two-part history of the Targaryens in Westeros. |
| LIVID | Patricia Cornwell | The 26th book in the Kay Scarpetta series. Scarpetta becomes a star witness in a televised murder trial and the judge’s sister is found dead. |
| THE PASSENGER | Cormac McCarthy | The first of a two-volume story. Bobby Western discovers things have gone missing from a jet in an underwater crash site, including the 10th passenger. |
| UGLY LOVE | Colleen Hoover | Tate Collins and Miles Archer, an airline pilot, think they can handle a no strings attached arrangement. But they can’t. |
| LONG SHADOWS | David Baldacci | The seventh book in the Memory Man series. Decker works with a new partner to investigate a double homicide. |
| FAIRY TALE | Stephen King | A high school kid inherits a shed that is a portal to another world where good and evil are at war. |
| WHERE THE CRAWDADS SING | Delia Owens | In a quiet town on the North Carolina coast in 1969, a young woman who survived alone in the marsh becomes a murder suspect. |
| MAD HONEY | Jodi Picoult and Jennifer Finney Boylan | After returning to her hometown, Olivia McAfee’s son gets accused of killing his crush. |
| DEMON COPPERHEAD | Barbara Kingsolver | A reimagining of Charles Dickens’s “David Copperfield” set in the mountains of southern Appalachia. |
| THE SEVEN HUSBANDS OF EVELYN HUGO | Taylor Jenkins Reid | A movie icon recounts stories of her loves and career to a struggling magazine writer. |
Overall, this notebook can be run weekly to get the up-to-date bestsellers list for fiction from The New York Times.