TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/dlampatricio/lamubi/llms.txt
Use this file to discover all available pages before exploring further.
/api/movies route is La Mubi’s internal data pipeline to TMDB. It pulls a randomised selection of high-quality movies — filtered by rating and popularity — and enriches each entry with full genre and crew data before returning the results to the client. The game store calls this endpoint at startup and automatically refills its queue whenever fewer than three movies remain.
Endpoint
Query Parameters
Number of movies to return. Clamped server-side to the range 1–20; values outside that range are silently corrected.
Response
A successful response is a JSON array ofMovieResult objects. Each object contains the following fields:
TMDB movie ID. Use this to construct a TMDB deep-link (e.g.
https://www.themoviedb.org/movie/{id}).The movie’s primary release title.
The TMDB poster path (e.g.
"/9cqNxx0GxF0bAY4bpuPKOsO88cI.jpg"). Prepend the TMDB image base URL to get a fully-qualified image URL:Four-digit release year extracted from the movie’s
release_date field (e.g. "1994").TMDB
vote_average formatted to exactly one decimal place (e.g. "8.7").The TMDB plot synopsis for the movie.
Ordered array of genre name strings as returned by TMDB (e.g.
["Drama", "Crime"]).Director name sourced from the movie’s credits crew.
undefined when no crew member with job: "Director" is present.Example Request
Example Response
Error Responses
| Status | Body | Cause |
|---|---|---|
404 | [] | TMDB discover returned zero results for the selected pages. |
500 | { "error": "No movies could be loaded" } | Every individual TMDB detail request (/movie/{id}) failed. |
500 | { "error": "TMDB error" } | An unexpected server-side error was thrown during the request. |
Selection Algorithm
The endpoint introduces randomness at the discovery stage rather than filtering a static list:- Page sampling — A random number of TMDB discover pages (between 2 and 5) is chosen, with each page number drawn randomly from the range 1–100.
- Pooling — All movie stubs from those pages are combined into a single array.
- Shuffling — The pool is shuffled using a Fisher-Yates shuffle to guarantee uniform distribution.
- Trimming — The first
countentries are selected from the shuffled pool. - Detail enrichment — A parallel
Promise.allSettledcall fetches/movie/{id}?append_to_response=creditsfrom TMDB for each selected movie, providinggenresand the fullcredits.crewarray.
| Filter | Value |
|---|---|
sort_by | vote_average.desc |
vote_count.gte | 1000 |
vote_average.gte | 7 |
language | en-US |
fetch calls use Next.js ISR with { next: { revalidate: 3600 } }, meaning responses are cached at the edge for one hour before the data is refreshed.
This is an internal Next.js API route. It is not a public REST API — it runs server-side and requires
TMDB_API_KEY to be set in the server environment. Calling it from an external host or without the environment variable will result in a 500 error.