omdb_end <- "http://www.omdbapi.com/?"
movie_title <- "t=Interstellar"
api_key <- "[Your API Key]"Movie Ratings Search
Introduction to the OMDb API
This API allows for developers to pragmatically search for characteristics of different movies including ratings, cast, and a brief summary of the plot. With this API a user can search for both specific movies like Interstellar but they can also search more broad terms like “Batman” and get results from all the movies that have “Batman” in the title. This information could be useful if someone wanted to compare how different movie rating sites differ in score based on any number of factors. More information on this can be found here: http://www.omdbapi.com/
Set-Up
In order to access this API the user much go to the website linked above, go to the “API-Key” header and fill out the short form to receive a free api-key in their email. Then, by using the the end point linked above and combining it with your own api-key the user can access the API. The only other necessary step is to pick which movie you would like to search for by replacing “Interstellar” with any movie of choice. This will then create a URL that can access the API and retrieve data.
omdb_url <- paste(omdb_end,apikey,movie_title,sep = "")Creating the Data Frame
Next we want to go from the API request URL to actually creating a data frame in r. We accomplish this by using the GET() function on our previously created URL, then we make sure the data is shown as “text” and in the JSON format. This will create a data frame with the information about the movie of choice. I took it one step further and created one that just had information on the ratings of the movie as that is what I was interested in.
movie_data <-
omdb_url %>%
GET() %>%
content(as = "text", encoding = "UTF-8") %>%
fromJSON()
ratings_df <- movie_data$RatingsData Cleaning and Visualization
Once I reviewed the data I realized that some of the ratings were in different formats and were categorical data types, so I created a new column that standardized the different rating formats into a numeric data column that was based on a 1-100 scale.
I then used this new column to show the difference in the ratings given to Interstellar by different rating sources.