<- "https://www.omdbapi.com/?"
db_endpoint <- "HERE" your_api_key
Open Movie Database API
How to Interact with the Open Movie Database API
The OMDb API allows users to interact with and search a database of thousands of movies and shows. The characteristics returned with each request include the rating, director, plot, awards, and much more! You can also filter your search by type (movie, series, episode), year of release, and more in cases such as remade movies and trilogies with similar names. For demonstration purposes, I will walk through the steps on how to retrieve information about one of the best Christmas movies ever made…Elf!
Step 1: Request API
Not all APIs require a personal API key, but this one does, so to do so one must…
- Go to this link: https://www.omdbapi.com/apikey.aspx
- Follow the ‘Free’ account type prompts and submit
- Check for an email and then click the bottom URL to activate
Then, you’re good to proceed!
Step 2: Load Necessary Packages & Create Values for the Endpoint Link and Your API Key
To simplify the step to follow, we will create values for our endpoint link and API key. This will also allow for ease of use, say in the case that your API key changes and you don’t want to change it more than once in the code.
Step 3: Create a Value for the Specific Movie
Here, we will create a value for our API link for the specific movie (Elf in this case) we would like to get information on.
<- "t=Elf" movie_title
Step 4: Create the URL
Append the endpoint, movie specification, and API key together to get the completed URL.
<-
omdb_api_url paste(db_endpoint,movie_title,your_api_key, sep ="")
Step 5: Create the Output!
In this step, we extract our requested data and convert it to a form that creates an easy-to-read data frame! Note that there will be multiple instances, which are unique in the fact that each displays different rating sources with respective scores.
<- omdb_api_url %>%
this_movie GET() %>%
content(as = "text",
encoding = "UTF-8") %>%
fromJSON(flatten = TRUE) %>%
as_tibble()
Summary
This is a fun API that can provide very useful information about any movie or show you want. Whether you’re getting in an argument with your friend over who directed a series or you’re curious how much money a film made from the box office, the possibilities are endless!