Hi,
I am new to the TMDB API and am trying to retrieve a list of movies from a specific year that have Albanian as their original language. However, I’m encountering some challenges with pagination and filtering.
I’m currently using the following API endpoint to get movies for the year 2022 with Albanian as the original language: https://api.themoviedb.org/3/discover/movie?api_key=MY_API_KEY&primary_release_year=2022&original_language=sq
The issue I’m facing is that the API returns results one page at a time, and given the large number of pages, it’s impractical to make a request for each page. Additionally, I’ve encountered a limit of 500 pages.
Could you please advise on the best approach to:
Efficiently retrieve all movies for a given year that match the specified original language. Handle the pagination effectively to avoid making excessive requests. Any guidance or alternative methods for achieving this would be greatly appreciated.
Thank you for your assistance.
Best regards, Fitore
Can't find a movie or TV show? Login to create it.
Want to rate or add this item to a list?
Not a member?
Reply by talestalker
on September 6, 2024 at 2:20 AM
Using discover method with
primary_release_year=
parameter is the way, but as for the language, you should usewith_original_language=
parameter, becauseoriginal_language=
parameter doesn't exist - see more hereYou must retrieve all pages separately (using
page=
parameter). If you want to speed things up, you can query first page to get a number of pages to retrieve and then fetch all remaining pages in parallel. Just keep in mind that you should throttle your request to API limit which is 50 requests per second.Reply by FitoreO
on September 6, 2024 at 3:52 AM
You are amazing! I missed the with part and when I added that to the link all the movies for that year with that language showed up. Thank you so much for your help!