API
TMDB Import
Admin API-driven TMDB import that populates the Supabase movies table
POST /api/admin/tmdb-import downloads TMDB's daily export and writes it into the Supabase movies table. The same endpoint is intended for local manual runs and production GitHub Actions schedules.
The import is network and database intensive. Run manual imports only when needed.
How It Works
- Builds a URL for yesterday's TMDB export (
movie_ids_MM_DD_YYYY.json.gz) - Downloads the gzipped NDJSON export and decompresses it in the import runner
- Parses each line as JSON and skips lines that are empty, invalid JSON, or do not match the expected TMDB export shape
- Filters out rows where
adult: trueorpopularity < 0.25 - Collects valid rows into batches of 1000
- Upserts each batch into
moviesontmdb_id - Only search-relevant fields are populated during import:
tmdb_id,original_title, andpopularity - Detailed metadata is filled later by
GET /api/movies/:id
Scheduling
Production scheduling is handled in GitHub Actions by sending authenticated POST requests to /api/admin/tmdb-import.
Result
Manual calls and GitHub Actions-triggered calls return the same object:
{
"imported": 312847,
"skipped": 14,
"adultExcluded": 4201,
"lowPopularityExcluded": 188932,
"durationSeconds": "47.83"
}
| Field | Description |
|---|---|
imported | Number of valid rows queued for Supabase upsert |
skipped | Rows skipped because they were empty, invalid JSON, or failed shape validation |
adultExcluded | Rows dropped because adult: true |
lowPopularityExcluded | Rows dropped because popularity < 0.25 |
durationSeconds | Wall-clock time for the full run, as a string with two decimal places |
Manual Trigger
POST /api/admin/tmdb-import
Runs the import on demand and returns the result object above. GitHub Actions should call this same endpoint for scheduled imports.
Headers
| Header | Description |
|---|---|
x-admin-token | Must match ADMIN_API_TOKEN in the server environment |
This endpoint does not accept a request body.
Error Codes
400request body was provided401missing or incorrectx-admin-token409another import is already running429too many failed admin-token attempts from the same IP502import failed because the TMDB export stream or Supabase write failed503ADMIN_API_TOKENis not configured
Environment Variables
| Variable | Description |
|---|---|
NUXT_PUBLIC_SUPABASE_URL | Supabase project URL |
NUXT_SUPABASE_SERVICE_ROLE_KEY | Required for server-side import writes |
ADMIN_API_TOKEN | Guards the manual trigger endpoint |