The Movie Database Support

Hi, When trying to use the Discover API to discover movies for a watch_region = 'US' and watch_provider = '9' which is Amazon Prime Video, I know that there are a total of 965 pages and 19,296 results.

I use the tmdbv3api Python wrapper to find this out:

provider_movies_in_country = discover.discover_movies({'with_watch_providers':'9', 'watch_region':'US'})
provider_movies_in_country['total_pages'], provider_movies_in_country['total_results']

However, when I try to go past the 500th page by doing:

discover.discover_movies({'with_watch_providers':'9' 'watch_region':'US','page':501})

or this:

url = "https://api.themoviedb.org/3/discover/movie?include_adult=false&include_video=false&language=en-US&page=501&region=US&sort_by=popularity.desc&with_watch_providers=9"

headers = {
    "accept": "application/json",
    "Authorization": "Bearer XXXX"
}

response = requests.get(url, headers=headers)

I get this error:

TMDbException: Invalid page: Pages start at 1 and max at 500. They are expected to be an integer.

How to get the remaining 465 pages of results? Thank you!

2 replies (on page 1 of 1)

Jump to last post

Hi @charlie.tran,

There is no way to go beyond page 500. Your best bet is to split up your query with another filter or two. My usual suggestion is to use primary_release_date.gte/primary_release_date.lte. You could split it up into years, or perhaps decades to keep the total within the valid 10,000 result window.

The number/quantity of Items per Page and the number/quantity of Pages
cannot be changed, configured, specified, restricted, or anything like that.
There will always be up to 20 items per page.
And a maximum of 500 pages.
Therefore, at most 10,000 items.

Of course, depending on the parameters used in your API Request
this number/quantity can be much smaller.
Eventually zero.

In a Trending API Request, the quantities are greater.
A maximum of 1,000 pages
Therefore a maximum of 20,000 items

Here's what Travis Bell, the Administrator, said on 2022-06-28:
https://www.themoviedb.org/talk/62bb2ea18b959e00526428c9#62bb37d2c613ce0094222e71

Unfortunately, there is no planned change on the page limit.
We still show the total results so one can get an accurate count but that is all.

A possible solution to your question.

How to get the remaining 465 pages of results?

If you filter by date or by votes then you can define ranges.
For example. Make a first Request using "&sort_by=primary_release_date.desc".

https://api.themoviedb.org/3/discover/movie?api_key=THE_KEY&language=en-US&sort_by=release_date.desc&page=1&with_watch_providers=9  

Check the date of the last item on page 500.
Assume it is 2003-10-25
Make a new Request using "&primary_release_date.lte=YYY-MM-DD" using a day before the last item.

https://api.themoviedb.org/3/discover/movie?api_key=THE_KEY&language=en-US&sort_by=release_date.desc&page=1&with_watch_providers=9&primary_release_date.lte=2003-10-26  

Repeat until you get all the movies.

Can't find a movie or TV show? Login to create it.

Global

s focus the search bar
p open profile menu
esc close an open window
? open keyboard shortcut window

On media pages

b go back (or to parent when applicable)
e go to edit page

On TV season pages

(right arrow) go to next season
(left arrow) go to previous season

On TV episode pages

(right arrow) go to next episode
(left arrow) go to previous episode

On all image pages

a open add image window

On all edit pages

t open translation selector
ctrl+ s submit form

On discussion pages

n create new discussion
w toggle watching status
p toggle public/private
c toggle close/open
a open activity
r reply to discussion
l go to last reply
ctrl+ enter submit your message
(right arrow) next page
(left arrow) previous page

Settings

Want to rate or add this item to a list?

Login