Why an API key is required
The Movie Database uses API keys to identify which application is making each request. This lets TMDB enforce fair-use rate limits, prevent abuse, and give developers visibility into their own usage through the TMDB dashboard. Every call the app makes — searching for movies, loading a show’s episodes, fetching a person’s filmography — includes your key as proof of authorization. Without a valid key, the TMDB API returns a401 Unauthorized error and no data is returned to the app.
Get your API key
1
Create a free TMDB account
Go to https://www.themoviedb.org/signup and register with your email address. You’ll receive a confirmation email — click the link to verify your account before proceeding.
2
Open your API settings
Log in and click your avatar in the top-right corner, then choose Settings. In the left-hand sidebar, select API.
3
Request an API key
Click Create under the “API Key (v3 auth)” section. TMDB will ask you to choose a key type — select Developer for personal or non-commercial use. Read and accept the API Terms of Use.
4
Fill in your application details
Complete the short application form with a name, description, and website for your project. These fields just help TMDB understand how the API is being used. You can enter your personal site URL or
http://localhost:3000 if you’re running the app locally.5
Copy your API key
After submitting, TMDB displays your new API Key (v3 auth) — a 32-character hexadecimal string that looks like this:Copy this key. You’ll also see a Read Access Token (v4 auth) — a longer JWT-style token used with API v4. Keep both values somewhere safe.
Add the key to the app
The TMDB app reads your API key from an environment variable so the key is never hard-coded into application source files. Create a.env file in the root of the project (next to package.json) if one does not already exist, then add the following line:
.env
your_api_key_here with the 32-character key you copied from TMDB. Save the file, then restart the development server. The app picks up the new variable automatically on the next start.
How the key is used in API requests
Depending on which version of the TMDB API an endpoint uses, the key is sent in one of two ways. API v3 — the key is appended as a query parameter on every request:Authorization header:
REACT_APP_TMDB_API_KEY environment variable.
Your v3 API key and your v4 Read Access Token are two separate credentials, both available on the same TMDB settings page. The v3 key is a short hex string; the v4 token is a long JWT. The app primarily uses v3 endpoints but falls back to v4 for certain account-based features. Configure only
REACT_APP_TMDB_API_KEY for the v3 key — the app derives the v4 token automatically from your TMDB session when needed.Security best practices
- Use environment variables — never paste your key directly into source code, component files, or configuration files that get committed to version control.
- Add
.envto.gitignore— do this before your first commit to ensure the file is never accidentally tracked. - Use
.env.example— commit a.env.examplefile with a placeholder value (REACT_APP_TMDB_API_KEY=) so collaborators know which variables to set without exposing real values. - Rotate compromised keys — if you accidentally expose your key, go to TMDB Settings → API and regenerate it immediately. Your old key becomes invalid at that point.
- Restrict usage on TMDB — the TMDB dashboard lets you see recent API usage. Monitor it periodically to catch unexpected spikes.
What to expect if the key is missing or invalid
If you’re seeing errors after adding your key, double-check that you restarted the dev server after editing
.env and that there are no extra spaces or quotes around the key value in the file.