omdbapi / OMDb-API

The Open Movie Database Bug Tracking
422 stars 21 forks source link

Request for adding parameter to specify page size #221

Open DonaldKellett opened 3 years ago

DonaldKellett commented 3 years ago

I'm currently following an archived edX course CS50M by Harvard and one of their exercises involves fetching movie information from the OMDb API.

I've just registered for a free API key and it states that the daily limit for the number of API calls is 1000, which should be enough for testing purposes, if it wasn't for the hardcoded limit of 10 results per page.

For example, searching for "Batman" yields 405 results at the time of writing (from the totalResults field of the returned JSON object), but the Search field only contains the results for the first page which is limited to 10 entries.

In order to obtain all of the results for this search entry in one go, I already have a rough idea of looping through the pages by making repeated calls to the API until the Search field is undefined, aggregating the results from all the pages and returning that as a single array. However, this means that I need to do about Math.ceil(405 / 10) = 41 API calls for each Batman search which would exhaust my daily quota in 25 searches or less.

For this reason, I would like to request for the page size to be configurable, and/or add an option for returning all the results at once, in order to minimize the number of API calls. Would that be possible? Thanks!

tgreve15 commented 3 months ago

It would be nice to have a parameter like this, but for your specific case why do you need to retrieve all results? Few people go to page 2 of a Google search let alone reaching the end. You know how many pages there will be, introduce paging on your interface and let the user decide which page they want. Or, how about picking a different search term to test that has more than a page but less total results.