Set Up the Credentials
Set up your credentials to get the API key for The Movie Database.
We'll cover the following
To use The Movie Database (TMDB) API platform, we need to create an account on TMDB.
Create an account
We can sign up for our TMDB account on their official page. Please follow the steps below to successfully sign up:
-
Fill in the primary details like username, password, and email address and click “Sign Up”.
-
Before you can log in to your account, you need to verify your email address to activate it. Go to your inbox and click the verification link in the verification email sent by TMDB.
-
Enter your username and password to log in.
-
A successful login would take you to the homepage of TMDB.
The slides below are to help you visualise the process.
Get the API key
Please follow the steps below to register for an API key:
- Log in to your TMDB account.
- Click on your name icon at the top right corner and then click “Settings” to go to the settings page.
- Click “API” to go to the API creation page.
- Click “click here” under the Request an API Key section.
- Select “Developer” as the type of your API.
- Click “Accept” to agree with the terms of use of TMDB API.
- Fill in the application details and click “Submit”.
Note: The “Application URL” field takes in any random URL as our application URL. For example, “www.example.com”.
- TMDB API key generated successfully!
The slides below are to help you visualise the process.
Let’s check whether we got our API key or not. If yes, let’s save it for this course. Click the “Edit” button below. Enter your API key and click “Save” to use it throughout the course.
print("Your TMDB API key is {{API_KEY}}")
Check your API key
Since we have our TMDB API key with us, get ready to do some great stuff! Here’s a sneak peek of how we can use our API key to fetch the required information. Let’s run the code below to fetch the popular movies on TMDB.
If you haven’t already entered your API_KEY
then please click “Edit” and enter the value. Now, click “Run” to execute the code.
import jsonimport requestsfrom pprint import pprintapi_key = '{{API_KEY}}'language = 'en-US'response = requests.get("https://api.themoviedb.org/3/movie/popular",params={'api_key':api_key,'language':language})#beautifying and printing the JSON responsepprint(response.json())
We’ll explore all such endpoints together throughout this course so let’s get started.