Using the New York Times Movie API, get review data and put it into a data frame.
library(jsonlite)
library(tidyverse)
## -- Attaching packages --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.2 v purrr 0.3.4
## v tibble 3.0.3 v dplyr 1.0.2
## v tidyr 1.1.1 v stringr 1.4.0
## v readr 1.3.1 v forcats 0.5.0
## -- Conflicts ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x purrr::flatten() masks jsonlite::flatten()
## x dplyr::lag() masks stats::lag()
#sections of the endpoint, broken up for ease of use
api_source = "https://api.nytimes.com/svc/movies/v2/reviews/search.json?"
key = "m7ydTuU2npl56mDBGEwVB3MCYJQ1SNFR"
#Change this to do different queries
query = "Disney"
#put it all together
endpoint = paste(api_source, "query=", query, "&api-key=", key, sep="")
JFrame = fromJSON(endpoint) %>% as.data.frame
#Remove some of the columns that are in the JSON payload, but not really useful for analysis.
JFrame = subset(JFrame, select = -c(1:4))
JFrame
## results.display_title results.mpaa_rating results.critics_pick
## 1 The Armor of Light PG-13 0
## 2 Balls Out R 1
## 3 Waking Sleeping Beauty PG 0
## 4 Disney's A Christmas Carol PG 0
## 5 American Violet PG-13 1
## 6 Disney's Teacher's Pet PG 1
## 7 Flubber PG 0
## 8 The Reluctant Dragon 0
## results.byline
## 1 NICOLAS RAPOLD
## 2 ANDY WEBSTER
## 3 STEPHEN HOLDEN
## 4 A. O. SCOTT
## 5 STEPHEN HOLDEN
## 6 Elvis Mitchell
## 7 Janet Maslin
## 8 T.S.
## results.headline
## 1 Review: ‘The Armor of Light’ Follows 2 Unlikely Allies Against Gun Violence
## 2 Review: ‘Balls Out,’ a Sports-Movie Satire Packed With ‘S.N.L.’ Talent
## 3 A Look at Famous Fables That Sing on the Screen
## 4 Ghosts of Technology Present
## 5 Fighting Injustice in Small-Town Texas
## 6 A Hand-Drawn Dog, Striving to Be Human
## 7 Flubber (Movie)
## 8 Reluctant Dragon, The
## results.summary_short
## 1 This documentary depicts a white evangelical conservative and the mother of a black shooting victim in Florida as they press their case.
## 2 “This isn’t about winning,” says the coach of the motley intramural football team at the center of this comedy. “It’s about winning at the last possible second.”
## 3 “Waking Sleeping Beauty” looks at the renaissance of Disney animation during the golden decade (1984-94).
## 4 “Disney’s A Christmas Carol,” written and directed by Robert Zemeckis, is a branded piece of shiny seasonal entertainment.
## 5 “American Violet,” which is based on real events that took place in late 2000, has the quasi-documentary feel of a well-made television drama.
## 6 It actually seems a sadly appropriate exercise of corporate short-sightedness that, just after Disney announced it was shutting down its Florida-based animation studios and bringing to a close the era of hand-drawn animation, the studio releases "Teacher's Pet." This marvelously quick-witted and gloriously goofy hand-drawn feature shows that there's still more than 21 grams of life left in the form. It helps when the drawn stuff has a touch of individuality, and the artist Gary Baseman — creator of both the Saturday morning cartoon show and this sure-footed, blessedly swift movie that was derived from it — couldn't be more idiosyncratic. Nathan Lane's shameless vocal theatrics is a perfect fit for the character he voices, Spot, a relentlessly chatty blue dog whose ambition to be a human boy instead of a doggy is realized by slipping into a pair of shorts, a bright yellow short-sleeved shirt and a pair of glasses. When Spot hears about Dr. Krank (Kelsey Grammer), the mad scientist who has perfected the technology of turning animals into humans, he scampers off to Florida to undergo treatment. "Teacher's Pet" will reward your close attention with a gratifyingly high ratio of humor. It gets more laughs out of 74 minutes than many recent live-action comedies with much more time. — Elvis Mitchell
## 7 Absent-minded inventor creates flying rubber. Nutty Robin, bogged down in too much blubbering.
## 8 Humorous tour of Disney Studio, including animation excerpts. Informal, enlightening, often winning.
## results.publication_date results.opening_date results.date_updated
## 1 2015-10-29 2015-10-30 2017-11-02 04:18:22
## 2 2015-06-18 2015-06-19 2017-11-02 04:18:21
## 3 2010-03-25 <NA> 2017-11-02 04:16:29
## 4 2009-11-05 2009-11-06 2017-11-02 04:18:10
## 5 2009-04-16 2009-04-17 2017-11-02 04:18:09
## 6 2004-01-16 2004-01-16 2017-11-02 04:18:03
## 7 1997-11-26 1997-11-26 2017-11-02 04:17:54
## 8 1941-07-25 1941-06-20 2017-11-02 04:17:03
## results.link.type
## 1 article
## 2 article
## 3 article
## 4 article
## 5 article
## 6 article
## 7 article
## 8 article
## results.link.url
## 1 http://www.nytimes.com/2015/10/30/movies/review-the-armor-of-light-follows-2-unlikely-allies-against-gun-violence.html
## 2 http://www.nytimes.com/2015/06/19/movies/review-balls-out-a-sports-movie-satire-packed-with-snl-talent.html
## 3 http://www.nytimes.com/2010/03/26/movies/26waking.html
## 4 http://www.nytimes.com/2009/11/06/movies/06disney.html
## 5 http://www.nytimes.com/2009/04/17/movies/17viol.html
## 6 http://www.nytimes.com/2004/01/16/movies/film-review-a-hand-drawn-dog-striving-to-be-human.html
## 7 http://www.nytimes.com/1997/11/26/movies/film-review-high-tech-gunk-returns-splat.html
## 8 http://www.nytimes.com/1941/07/25/archives/-the-reluctant-dragon-a-walt-disney-compound-of-fact-and-fancy.html
## results.link.suggested_link_text
## 1 Read the New York Times Review of The Armor of Light
## 2 Read the New York Times Review of Balls Out
## 3 Read the New York Times Review of Waking Sleeping Beauty
## 4 Read the New York Times Review of Disney's A Christmas Carol
## 5 Read the New York Times Review of American Violet
## 6 Read the New York Times Review of Disney's Teacher's Pet
## 7 Read the New York Times Review of Flubber
## 8 Read the New York Times Review of The Reluctant Dragon
## results.multimedia.type
## 1 mediumThreeByTwo210
## 2 mediumThreeByTwo210
## 3 <NA>
## 4 <NA>
## 5 <NA>
## 6 <NA>
## 7 <NA>
## 8 <NA>
## results.multimedia.src
## 1 https://static01.nyt.com/images/2015/10/30/arts/30ARMOR1/30ARMOR1-mediumThreeByTwo210.jpg
## 2 https://static01.nyt.com/images/2015/06/19/arts/19BALLSOUT/19BALLSOUT-mediumThreeByTwo210-v2.jpg
## 3 <NA>
## 4 <NA>
## 5 <NA>
## 6 <NA>
## 7 <NA>
## 8 <NA>
## results.multimedia.width results.multimedia.height
## 1 210 140
## 2 210 140
## 3 NA NA
## 4 NA NA
## 5 NA NA
## 6 NA NA
## 7 NA NA
## 8 NA NA
Conclusion: I really liked the NYT approach to this, it was very easy to follow the flow of their website from creating an account, to getting my api key set up. There documentation is also very good, the query langauge they use is very similar to SQL, and that is probably on purpose, no need to reinvent the wheel here. Originally i wanted to find an API that leveraged the NYT recipe archive, but i couldn’t find one, so that was kind of a bummer.