I am writing an application in Perl to display movies released in the last week. I have the code working, but it's slow. I call the API with discover/movie to get all the newly released movies, and then call the API with movie/{id}/releases for each of the movies so I can extract only movies with US releases. This code takes about 10 seconds. Then I call the API with movie/{id} to get basic information about each of the movies. This portion takes about 13 seconds. So, to get a complete list of US-released movies for one week takes about 23 seconds (depending on how many movies were released that week). This is obviously slow. If I want to use the API for this purpose, is it expected that I write code to download the entire database, update the data periodically, and access the data locally?
Не можете найти фильм или сериал? Войдите на сайт, чтобы добавить его.
Хотите поставить оценку или добавить в список?
Нет аккаунта?
Ответ от Travis Bell
, 14 августа 2013 в 10:20
Hi celiao,
A few things.
Use
?append_to_response
so you only have to make the movie call with releases once. That's half as many calls as you're currently making.Depending on the way the interface works, most people don't go and query every page of the discover results. Most UI's might only show 10 items at a time, so you can only grab the first page and as the user scrolls be loading more pages behind the scene. This way you're only grabbing 20 items at a time. For examples of this depending what platform you're on, there's a number of apps you can see who have implemented something like that on our apps page.
We let you do approximately 3 requests per second so you can do multiple requests at a time if you spun up concurrent requests.
Depends what you're trying to build. Lots of apps just query our DB directly while others are doing a lot more custom things that require their own DB.