WhatsApp Chat Sentiment Analysis in R

How To Extract Movie Data From The Movie Database | R Programming

Objective: To extract the movie data from TMDB using R programming.

Step 1: Generate API Key provided by The Movie DB

The process of generating API is very simple and available to everyone for free of cost. Follow the following steps to generate personalised API Key for yourself.

i) Go to the Website.

ii) Click on the SIGN UP.

iii) After signing up and verifying your email address, go to your profile setting and click on the API         tab.

iv) Click "Create" from the API page fill all the details required.

Step 2: Install and load required package.

> install.packages("TMDb")

> library(TMDb)

TMDb Provides an Rinterface to the TMDb API. The Movie Database (TMDb) is a popular user editable database for movies and TV shows. To learn more about the package click HERE

Step 3: Explore different functions to find required data about movies.

To find the top rated movies use following code 

> api_key <- "ca********************8" #Insert Your Unique API Key
> Top_rated_movies <- movie_top_rated(api_key, page = 1, language = "en")
> Top_rated_movies

Setting page as 1 will give around 20 top rated movies while you can set it upto 1000. For language code refer to A ISO 639-1 codes.

To save the Top rated movies as data frame

> TRM <- as.data.frame(Top_rated_movies$results$original_title)

To save the file as CSV in your system

> write.csv(TRM, file = "TRM.csv")

To find the top rated tv series 

> top_rated_tvseries <- tv_top_rated(api_key, page = 1, language = "en")
> top_rated_tvseries$results$original_name