Set Up the Credentials

Set up your credentials to get the API key for The Movie Database.

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:

  1. Fill in the primary details like username, password, and email address and click “Sign Up”.

  2. 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.

  3. Enter your username and password to log in.

  4. 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:

  1. Log in to your TMDB account.
  2. Click on your name icon at the top right corner and then click “Settings” to go to the settings page.
  3. Click “API” to go to the API creation page.
  4. Click “click here” under the Request an API Key section.
  5. Select “Developer” as the type of your API.
  6. Click “Accept” to agree with the terms of use of TMDB API.
  7. 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”.

  1. 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 json
import requests
from pprint import pprint
api_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 response
pprint(response.json())

We’ll explore all such endpoints together throughout this course so let’s get started.