Week 9 Homework

Nick Oliver

Week 9 Homework

In this assignment the goal is to retrieve and load JSON data from the New York Times open data APIs. I chose to use the movie reviews API that they offer to load my data in. The reviews API has a search.json route which includes a critics-pick query parameter that I used in order to retrieve 20 movie reviews in JSON format.

Setup

Load Libraries

For this assignment I only needed two libraries. The kableExtra library is used for displaying my data for review purposes. The jsonlite library does the heavy lifting of retrieving and parsing the data.

library(kableExtra)
library(jsonlite)

Load Raw JSON from NYT

I found the full route for the API by using the New York Times documentation website. My API key is embedded in the URL as a query parameter.

The jsonlite library includes a function called fromJSON which not only is able to make the HTTP GET request to the NYT API but also parses the results into a list of data.

url <- 'https://api.nytimes.com/svc/movies/v2/reviews/search.json?critics-pick=Y&api-key=FIU5RW8zWaF0jp8Y0w76rUlhusYdmagW'
results <- fromJSON(url)

The result of the fromJSON request is a 5 item list.

The first item in the list represents the status of the response I am extracting that value and validating that it equals "OK"

The last item in the list is the actual response body already in a dataframe. I simply extract that body as a dataframe and display it in a table.

status <- results[[1]]
print(paste("Response Status: ", status))
## [1] "Response Status:  OK"
if(status != "OK"){
  print("Request failed!")
}else{
 rawDf <- results[[5]]
 rawDf %>% 
   kbl() %>%
     kable_paper(full_width = F) %>%
    scroll_box(width = "100%", height="600px")
}
display_title mpaa_rating critics_pick byline headline summary_short publication_date opening_date date_updated link multimedia
Dune PG-13 1 Manohla Dargis ‘Dune’ Review: A Hero in the Making, on Shifting Sands Denis Villeneuve’s adaptation is an equally sweeping and intimate take on Frank Herbert’s future-shock epic. 2021-10-20 2021-10-22 2021-10-20 22:47:07 article mediumThreeByTwo210
Wheel of Fortune and Fantasy 1 Manohla Dargis ‘Wheel of Fortune and Fantasy’ Review: What We Talk About In three stories, men and women circle one another as they casually and cruelly share intimacies, express desires and voice doubts. 2021-10-14 2021-10-15 2021-10-14 17:11:03 article mediumThreeByTwo210
The Velvet Underground R 1 A.O. Scott ‘The Velvet Underground’ Review: And Me, I’m in a Rock ’n’ Roll Band Todd Haynes’s documentary paints a jagged, revelatory portrait of the New York avant-garde scene of the 1960s. 2021-10-14 2021-10-15 2021-10-14 16:24:03 article mediumThreeByTwo210
Bergman Island R 1 A.O. Scott ‘Bergman Island’ Review: Love Among the Cinephiles In Mia Hansen-Love’s new film, Vicky Krieps and Tim Roth play filmmakers on the rocks in the Baltic Sea. 2021-10-14 2021-10-15 2021-10-14 16:01:05 article mediumThreeByTwo210
Noroît Not Rated 1 Glenn Kenny ‘Noroît’ Review: In a French Vision, Pirates Inhabit a Jacobean Drama When this unusual film, made in 1976 by the French director Jacques Rivette, opens in New York this week, it will be making its official debut here. 2021-10-14 NA 2021-10-14 13:42:42 article mediumThreeByTwo210
The Last Duel R 1 Manohla Dargis ‘The Last Duel’ Review: A Medieval Epic in the Age of #MeToo Ridley Scott and his all-star cast rip the moldy fig leaf off chivalric romance in a he-said, he-said, she-said spectacle. 2021-10-13 2021-10-15 2021-10-13 22:08:03 article mediumThreeByTwo210
Son of Monarchs R 1 Isabelia Herrera ‘Son of Monarchs’ Review: Of Butterflies and Belonging This lush Mexican drama tells a story about climate change and cultural identity using the allegory of monarch butterflies’ migration. 2021-10-13 2021-11-02 2021-10-13 17:53:03 article mediumThreeByTwo210
Fever Dream R 1 Nicolas Rapold ‘Fever Dream’ Review: Touching From a Distance Claudia Llosa’s adaptation of Samanta Schweblin’s novel casts a spell, evoking more than it explains. 2021-10-13 2021-10-13 2021-10-13 11:01:03 article mediumThreeByTwo210
Lamb R 1 Jeannette Catsoulis ‘Lamb’ Review: Oh No, Not My Baby! A strange birth on an Icelandic farm bodes ill for a grieving couple in this eerie debut feature. 2021-10-07 2021-10-08 2021-10-07 21:42:03 article mediumThreeByTwo210
Jacinta 1 Beatrice Loayza ‘Jacinta’ Review: A Neverending Cycle of Hurt This haunting documentary by Jessica Earnshaw traces the journey of a young woman struggling with addiction after her release from prison. 2021-10-07 2021-10-08 2021-10-07 11:02:03 article mediumThreeByTwo210
V/H/S/94 1 Calum Marsh ‘V/H/S/94’ Review: The Right Snuff This lo-fi horror omnibus is a grisly, gory gem. 2021-10-06 2021-10-06 2021-10-06 11:01:03 article mediumThreeByTwo210
Karen Dalton: In My Own Time 1 Glenn Kenny ‘Karen Dalton: In My Own Time’ Review: An Elemental Musical Force A documentary chronicles the turbulent life of a singer whose music made a substantial impression on New York’s 1960s folk scene and still resonates today. 2021-09-30 NA 2021-09-30 15:41:03 article mediumThreeByTwo210
The Guilty R 1 Jeannette Catsoulis ‘The Guilty’ Review: Dial R for Redemption Jake Gyllenhaal plays an imploding 911 operator in this riveting remake. 2021-09-30 2021-10-01 2021-09-30 11:11:03 article mediumThreeByTwo210
I’m Your Man R 1 Jeannette Catsoulis ‘I’m Your Man’ Review: Living Doll Dan Stevens plays a dreamy, pleasure-driven android in this delightful near-future romance. 2021-09-23 2021-09-24 2021-09-23 11:03:03 article mediumThreeByTwo210
The Village Detective: a song cycle 1 Glenn Kenny ‘The Village Detective: A Song Cycle’ Review: Soviet Film Hero Emerges Bill Morrison, the poet laureate of lost films, turns the story of footage found near Iceland into a history of a slice of Soviet cinema. 2021-09-22 NA 2021-09-22 22:17:53 article mediumThreeByTwo210
In Balanchine’s Classroom 1 Teo Bugbee ‘In Balanchine’s Classroom’ Review: Teaching the Ineffable Former ballet dancers grasp at words to describe the genius of George Balanchine in this charming documentary. 2021-09-16 2021-09-17 2021-09-16 19:21:11 article mediumThreeByTwo210
Little Girl 1 Beatrice Loayza ‘Little Girl’ Review: Growing Up and Seeking Peace This sensitive documentary by the French filmmaker Sébastien Lifshitz naturalistically explores the struggles of a 7-year-old transgender girl. 2021-09-16 2021-09-17 2021-09-16 15:15:03 article mediumThreeByTwo210
Cry Macho PG-13 1 A.O. Scott ‘Cry Macho’ Review: The Good, the Bad and the Poultry In his latest film, Clint Eastwood drives across Mexico with a troubled young man and a combative rooster. 2021-09-16 2021-09-17 2021-09-16 11:07:02 article mediumThreeByTwo210
Wife of a Spy 1 Glenn Kenny ‘Wife of a Spy’ Review: Trust or Fear in Love and War? In this latest work by Kiyoshi Kurosawa, a Japanese couple’s relationship is shaped by the forces of churning nationalism that surround it. 2021-09-16 2021-09-17 2021-09-16 11:06:02 article mediumThreeByTwo210
The Card Counter R 1 Manohla Dargis ‘The Card Counter’ Review: A Gambler’s Existential Solitaire Oscar Isaac, Tiffany Haddish and Willem Dafoe star in the latest head trip from Paul Schrader, a story about betting on life. 2021-09-09 2021-09-10 2021-09-09 19:18:03 article mediumThreeByTwo210