OMDb-API icon indicating copy to clipboard operation
OMDb-API copied to clipboard

How to get more than 10 results?

Open ggtenev opened this issue 5 years ago • 5 comments

How do we get more than 10 results in our response object? I can't find any parameters for that

ggtenev avatar Mar 06 '20 04:03 ggtenev

It's hard coded I believe. You'll need to implement pagination using the totalResults value

jewkesy avatar Mar 16 '20 07:03 jewkesy

For an individual search, it looks like the API returns a maximum of 10 results per page, and your default search has an implicit "&page=1" at the end of it.

So your first search might go something like:

JavaScript:

(apiUrl + "&s=" + your-search-term)

where apiUrl is your personal OMDb API key URL. This is the same thing as searching:

JavaScript:

(apiUrl + "&s=" + your-search-term + "&page=1")

So if you want to get the next set of results, you would need to iterate that page number upwards. You could build something like pagination in a series of buttons at the end of your search results like you see on a retail site.

If you want to display more than 10 results per search as a default, I suspect you'll need to send a double request. Your user would only "submit" once, but you would build your function to perform two searches, or however many you actually need.

You would then push those responses into a single array, and use that array to generate the displayed content. You could then manipulate that array if you wanted to present something other than multiples of ten.

jafarlow avatar Apr 29 '20 10:04 jafarlow

You can get the total no. of results by using s=your_title_name example http://www.omdbapi.com/?i=tt3896198&apikey=your_api&s=title try this

pankajsahu221 avatar Sep 14 '20 10:09 pankajsahu221

You can get the total no. of results by using s=your_title_name example http://www.omdbapi.com/?i=tt3896198&apikey=your_api&s=title try this

what is this ?i=tt3896198 ?

luis-fern4ndo avatar Jan 08 '21 17:01 luis-fern4ndo

what is this ?i=tt3896198 ?

This is a valid IMDb ID.

Any solution on how to get more results from API?

AdityaNathK avatar Jun 15 '21 04:06 AdityaNathK