Hi, I've created a front-end application that directly consumes the TMDB api.
In this application, I have an array of strings that correspond to a simple list of movie names.
So I wanted to make a for loop via this array, to retrieve the data from this url
https://api.themoviedb.org/3/search/tv?query=${query}
I got this error: “Too many requests”. (Makes sense...)
I'd like to know how I can go about avoiding this, as I haven't found a solution in the document.
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 noodlecat
on July 18, 2024 at 9:09 PM
may be the request too fast so that cause the error,you can use 'setTimeout' function to delay these request
Reply by ticao2 🇧🇷 pt-BR
on July 19, 2024 at 10:34 AM
Perhaps the following will help resolve your issue.
API Request Limits
First we have this information in the instructions for using the TMDb API.
https://developer.themoviedb.org/docs/rate-limiting
And Travis Bell, the Administrator, has already given us this explanation.
For API Requests:
See here: https://www.themoviedb.org/talk/62c7c1b258361b005fd2e747?page=1#62c83b78befd91005007a0c7
For Images:
See here:
https://www.themoviedb.org/talk/62edd3ca46aed400917de201#62ee88e7176a940086449cdf
https://www.themoviedb.org/talk/62c7c1b258361b005fd2e747?page=1#6301a107097c49007f60374a
https://www.themoviedb.org/talk/62c7c1b258361b005fd2e747
And...
Is there really no API Rate Limiting?
See here:
https://www.themoviedb.org/talk/6442ced4d35dea02fcfb0fab#6442d4a0d35dea0455fb1a07
In this link I believe you can see your volume of API Requests.https://www.themoviedb.org/sessionReply by Travis Bell
on July 19, 2024 at 11:22 AM
@ticao2 that request count is only for the website, it doesn't relate to the API in any way.
@noodlecat The easiest way to help with your issue is it to introduce a small delay in between every requests so that you are issuing more than ~40 per second. There are fancier designs where you can keep track of the number of requests in a second, and then limit the number you execute within a threshold of sorts. It's really up to you how you want to implement this.
Reply by Maxime145
on July 21, 2024 at 10:15 AM
Thanks for your answers !
The “delay” solution doesn't work for me because it's impractical to deal with single-call errors. What's more, I get around 120 calls every time I refresh my page.
I ended up making a back application with rudimentary cache management. And on the front-end, I simply send the names to be retrieved. This reduces the number of calls to the TMDB API.