loading packages

library(httr)
library(jsonlite)

NYT API

urls = 'https://api.nytimes.com/svc/movies/v2/reviews/search.json?api-key='

Request from NYT API

r = GET(paste(urls,key))
data = content(r,as = 'text')

Transforming to R Dataframe

to_df = fromJSON(data)
reviews = to_df$results
head(reviews)
##   display_title mpaa_rating critics_pick              byline
## 1                                      0   Natalia Winkelman
## 2 Future People                        0   Natalia Winkelman
## 3 Thunder Force       PG-13            0 Jeannette Catsoulis
## 4    Shiva Baby                        1        Jason Bailey
## 5        Moffie                        0         Glenn Kenny
## 6    The Tunnel                        0     Beatrice Loayza
##                                                       headline
## 1 ‘Future People’ Review: Connected by Biology, Bonded by Love
## 2 ‘Future People’ Review: Connected by Biology, Bonded by Love
## 3 ‘Thunder Force’ Review: Saving Chicago, One Mutant at a Time
## 4                        ‘Shiva Baby’ Review: It’s Complicated
## 5                       ‘Moffie’ Review: A Bleak Coming-of-Age
## 6                        ‘The Tunnel’ Review: Fire in the Hole
##                                                                                                                                                summary_short
## 1 This documentary chronicles eight years in the lives of a group of children who form a bond after discovering they were conceived by the same sperm donor.
## 2 This documentary chronicles eight years in the lives of a group of children who form a bond after discovering they were conceived by the same sperm donor.
## 3                                                            Melissa McCarthy and Octavia Spencer don superhero suits in this painfully lazy Netflix comedy.
## 4                                The potential land mines of a young woman’s life are set to explode simultaneously in this tense comedy from Emma Seligman.
## 5           This grueling film about the South African military going to war with Angola is replete with vicious, stark depictions of racism and homophobia.
## 6                                                Painfully cliché but sufficiently diverting, this is the latest in a string of disaster movies from Norway.
##   publication_date opening_date        date_updated link.type
## 1       2021-04-09         <NA> 0001-01-01 00:00:00   article
## 2       2021-04-09   2021-01-01 2021-04-09 11:36:02   article
## 3       2021-04-09   2021-04-09 2021-04-09 07:02:03   article
## 4       2021-04-08   2021-04-02 2021-04-08 15:29:03   article
## 5       2021-04-08   2021-04-09 2021-04-08 11:01:03   article
## 6       2021-04-08         <NA> 2021-04-08 11:03:03   article
##                                                                            link.url
## 1               https://www.nytimes.com/2021/04/09/movies/future-people-review.html
## 2               https://www.nytimes.com/2021/04/09/movies/future-people-review.html
## 3               https://www.nytimes.com/2021/04/09/movies/thunder-force-review.html
## 4                  https://www.nytimes.com/2021/04/08/movies/shiva-baby-review.html
## 5                      https://www.nytimes.com/2021/04/08/movies/moffie-review.html
## 6 https://www.nytimes.com/2021/04/08/movies/the-tunnel-review-fire-in-the-hole.html
##                          link.suggested_link_text     multimedia.type
## 1              Read the New York Times Review of  mediumThreeByTwo210
## 2 Read the New York Times Review of Future People mediumThreeByTwo210
## 3 Read the New York Times Review of Thunder Force mediumThreeByTwo210
## 4    Read the New York Times Review of Shiva Baby mediumThreeByTwo210
## 5        Read the New York Times Review of Moffie mediumThreeByTwo210
## 6    Read the New York Times Review of The Tunnel mediumThreeByTwo210
##                                                                                                                               multimedia.src
## 1                                                    https://static01.nyt.com/images/2021/04/10/arts/future1/future1-mediumThreeByTwo440.jpg
## 2                                                    https://static01.nyt.com/images/2021/04/10/arts/future1/future1-mediumThreeByTwo440.jpg
## 3                                               https://static01.nyt.com/images/2021/04/09/arts/thunder1/thunder1-mediumThreeByTwo440-v3.jpg
## 4                                                      https://static01.nyt.com/images/2021/04/10/arts/shiva1/shiva1-mediumThreeByTwo440.jpg
## 5 https://static01.nyt.com/images/2021/04/09/arts/08moffie-art/merlin_185829336_1fbc3aa3-1601-4481-8081-e0e40959360d-mediumThreeByTwo440.jpg
## 6                                                    https://static01.nyt.com/images/2021/04/06/arts/tunnel1/tunnel1-mediumThreeByTwo440.jpg
##   multimedia.height multimedia.width
## 1               140              210
## 2               140              210
## 3               140              210
## 4               140              210
## 5               140              210
## 6               140              210

conclusion: API’s provide an easy and efficient way to obtain data