Live requests hit the real TMDB API

Learn how APIs actually work.

Not just theory β€” send real HTTP requests to The Movie Database API from this page, watch the exact request and response payloads, and learn to read API docs like an engineer.

πŸ–₯️
Your browser
πŸ€–
GoodBoyRobot.com
(this site)
🎬
TMDB API
GET /search/movie?query=inception
01 β€” Fundamentals

What is an API, really?

An API (Application Programming Interface) is a contract: a defined set of requests a program can make, and the responses it can expect back. Think of a restaurant β€” you (the client) don't walk into the kitchen (the server). You tell the waiter (the API) what you want from the menu (the documentation), and the kitchen sends back your order in a predictable format.

πŸ“œ

It's a contract

The docs define exactly which URLs exist, what parameters they accept, and what shape the response takes. Nothing more, nothing less.

πŸ”’

It hides complexity

TMDB has a massive database and recommendation engine behind it. You never see that β€” you just ask /movie/27205 and get JSON back.

πŸ”

It's request β†’ response

Almost every web API works the same basic loop: you send a request, the server processes it, and sends back a response β€” every single time.

🌐

Usually HTTP

Most modern APIs β€” including TMDB's β€” speak HTTP, the same protocol your browser uses to load web pages. Same verbs, same status codes.

πŸ“¦

Payloads are just data

A "payload" is the actual data being sent or returned β€” usually as JSON. No magic, just structured text.

πŸ”‘

Often needs auth

APIs identify who's calling, usually via an API key or token, so they can rate-limit, bill, or restrict access.

02 β€” Anatomy

Anatomy of an API request

Click each colored part of this real TMDB request URL to see what it means.

Scheme Host Path Query string
https://api.themoviedb.org/3/search/movie?query=inception&page=1
hover or click a part above

The URL is the address of the exact resource or action you're asking for. Everything after the host is up to the API's documentation to define.

03 β€” Documentation

Reading TMDB's docs like an engineer

Every API's documentation follows roughly the same shape. Here's how developer.themoviedb.org is organized, and what each part tells you.

04 β€” Authentication

Why your API key never belongs in the browser

TMDB gives you an API Key (v3) and a Read Access Token (v4, a Bearer token). Both are secrets. If your JavaScript calls TMDB directly, anyone can open DevTools β†’ Network tab and steal it.

❌ Calling TMDB directly from the browser

Browser β†’ fetch() with Bearer eyJhbGci...
Browser ──────────────────────→ TMDB

Anyone viewing your page's source or network requests now has your token and can use your quota β€” or worse, run up costs / get you rate-limited or banned.

βœ… Routing through your own server

Browser β†’ fetch() to
Your PHP β†’ adds β†’ TMDB

This is exactly what this page does. Open the Network tab during the playground below β€” you'll only ever see requests to /api/tmdb.php, never to TMDB directly.

05 β€” Try it live

The playground

Pick a real TMDB endpoint, fill in parameters, and send it. You'll see exactly what request left your server, and exactly what came back.

↑ These buttons use htmx directly: hx-get="api/tmdb.php?..." β€” no JavaScript written for the click, just an attribute.

GET

β–Έ Requesti

Press "Send request" to build one…

β–Ύ Responsei

Waiting for a request…
⚑ This panel uses plain fetch() instead of htmx, because we need to build the JSON tree view and reuse the same result in two columns β€” htmx is for swapping HTML fragments, not full client-side rendering logic.
06 β€” Behavior

Status codes: how APIs tell you what happened

Click a card to send a real request that demonstrates that outcome.

200

OK

Everything worked. The body contains the data you asked for.

404

Not Found

The resource (e.g. that movie ID) doesn't exist. Check the URL/params.

401

Unauthorized

Missing or invalid credentials β€” the API doesn't know who you are.

422 / 400

Bad Request

Your request is malformed β€” a required param is missing or invalid.

5xx

Server Error

Something broke on the API's side. Not your fault β€” usually worth retrying.

429

Too Many Requests

You've hit the rate limit. Back off and check the Retry-After header.

07 β€” Payloads

What a payload actually looks like

"Payload" just means the data traveling in the request or response body. TMDB's read endpoints are all GET (no request body β€” params ride in the URL), so here's a real GET/response pair alongside an illustrative POST payload for comparison.

GET Real: fetching a movie

No request body. Everything needed is in the URL.

GET /3/movie/27205?append_to_response=credits
Host: api.themoviedb.org
Authorization: Bearer <token>
Accept: application/json

POST Illustrative: rating a movie

TMDB's real "add rating" endpoint needs a session id we won't set up here β€” this shows the shape of a POST payload.

POST /3/movie/27205/rating
Host: api.themoviedb.org
Authorization: Bearer <token>
Content-Type: application/json

{
  "value": 8.5
}

The response payload for that GET

This is real, live data returned just now by TMDB for movie id 27205 (Inception) β€” rendered as a collapsible tree so you can explore its shape.

Loading a live sample…
08 β€” Check yourself

Quick knowledge check

Twenty questions covering everything above. No pressure β€” just a gut check.