This database allows for you to access information about movies, such as
Title - Title of the movie
Year - Year the movie came out
Rated - MPA rating
Released - The date the movie debuted
Runtime - How long the movie is
Genre - What genre the film falls under
Director - Who directed the movie
Writer - Who wrote the script for the film
Actors - A few of the actors who have big roles
Plot - A short description of what the movie is about
Language - The language spoken in the movie
Country - The country the movie was made in
Awards - If the movie was nominated for an Oscar or other awards
Poster - A link to the movie poster
Ratings - The ratings a movie got from different sources like IMDB or Rotten Tomatoes
Running Code
First, I will install my packages and get the first chunk of the API set on up. I believe all of these packages are needed, but to be fully honest I get confused on what I use from each package. The first part of the API is given by the website https://www.omdbapi.com/.
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.4.4 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.0
✔ purrr 1.0.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(jsonlite)
Attaching package: 'jsonlite'
The following object is masked from 'package:purrr':
flatten
library(magrittr)
Attaching package: 'magrittr'
The following object is masked from 'package:purrr':
set_names
The following object is masked from 'package:tidyr':
extract
first_part <-"http://www.omdbapi.com/?"
Next, I will go get my personal key, which i also got from the website https://www.omdbapi.com/. Make sure you get and use your own!!! In order to not display mine I have hidden it, but I will provide an example of what the format should be
#api_key=<YOUR-API-KEY-HERE>"
I will now select a movie to look at. Personally, I recommend ’The Lego Movie”, as I am trying to raise awareness for this classic! There are several ways to search, such as title, IMDB number, release year, or type of content, but to keep thing simple I am just using title in this example. I am using a + for the spaces as that is what the sample on the website uses.
title <-"t=The+Lego+Movie"
I will now attempt to run the API call for this cinematic work and get the data into R! I will combine all of my URL bits, then pipe URL into R.
This has worked! We can now read about The Lego Movie and all of it’s accomplishments in R!
print(api_data)
$Title
[1] "The Lego Movie"
$Year
[1] "2014"
$Rated
[1] "PG"
$Released
[1] "07 Feb 2014"
$Runtime
[1] "100 min"
$Genre
[1] "Animation, Action, Adventure"
$Director
[1] "Phil Lord, Christopher Miller"
$Writer
[1] "Phil Lord, Christopher Miller, Dan Hageman"
$Actors
[1] "Chris Pratt, Will Ferrell, Elizabeth Banks"
$Plot
[1] "An ordinary LEGO construction worker, thought to be the prophesied as \"special\", is recruited to join a quest to stop an evil tyrant from gluing the LEGO universe into eternal stasis."
$Language
[1] "English, Turkish"
$Country
[1] "United States, Denmark, Australia, Norway"
$Awards
[1] "Nominated for 1 Oscar. 72 wins & 67 nominations total"
$Poster
[1] "https://m.media-amazon.com/images/M/MV5BMTg4MDk1ODExN15BMl5BanBnXkFtZTgwNzIyNjg3MDE@._V1_SX300.jpg"
$Ratings
Source Value
1 Internet Movie Database 7.7/10
2 Rotten Tomatoes 96%
3 Metacritic 83/100
$Metascore
[1] "83"
$imdbRating
[1] "7.7"
$imdbVotes
[1] "386,661"
$imdbID
[1] "tt1490017"
$Type
[1] "movie"
$DVD
[1] "31 Oct 2015"
$BoxOffice
[1] "$257,966,122"
$Production
[1] "N/A"
$Website
[1] "N/A"
$Response
[1] "True"
Data Visualization
The Lego Movie was go good it warranted a direct sequel, The Lego Movie 2: The Second Part. While both equally exceptional works of art, I would like to see which one did better in the box office. To do this, I will run another API call for the sequel.
This gives us a little table, but it captures each movie 3 times due to each review source causing a new row. To get around this, I will compare the two movies by setting them to have a mutual review source.