The Open Movie Database (OMDb) API provides access to information about movies
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.5.2 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.1.0
## ── 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
library(httr)
t = movie title s = Search keyword i = IMDB ID type = “movie”, “series”, or “episode” y = year of release plot = “short” or “full”
omdb_endpoint <- “https://www.omdbapi.com/” api_key <- “apikey=cc7d9ef9” # PLEASE! Replace with your own API key
title <- “&t=Toy Story” plot <- “&plot=short”
omdb_api_url <- paste0(omdb_endpoint, “?”, api_key, title, plot)
omdb_api_url
omdb_api_url <- “https://www.omdbapi.com/?t=Toy%20Story&apikey=cc7d9ef9&plot=short” omdb_response <- GET(omdb_api_url) movie_data <- fromJSON(content(omdb_response, “text”)) write.csv(movie_data, “toy_story.csv”, row.names = FALSE)
toy_story <- read.csv(“toy_story.csv”) toy_story