The Movie Database Support

hi, am requesting to discover action category https://api.themoviedb.org/3/discover/movie?api_key=###&sort_by=popularity.desc&with_genres=28 and i get only 1 page details , i can specify a page but i want to get all the movies available in the pages! how to do that? i have seen apps with all of a genres movies so it must be possible!

10 replies (on page 1 of 1)

Jump to last post

Hi @Yaseen55,

You need to use the page parameter.

https://api.themoviedb.org/3/discover/movie?api_key=###&sort_by=popularity.desc&with_genres=28&page=1
https://api.themoviedb.org/3/discover/movie?api_key=###&sort_by=popularity.desc&with_genres=28&page=2
https://api.themoviedb.org/3/discover/movie?api_key=###&sort_by=popularity.desc&with_genres=28&page=3

Etc...

Hi @travisbell i know that as i said i can specify the page but like that if there is 500 pages out there i have to send 500 requests!!

Hi @Yaseen55.

You are right: the only way to get all results is to process each result page (and to use 500 requests in your example). You cannot specify in the request the number of results by page.

Best regards.

i know that as i said i can specify the page but like that if there is 500 pages out there i have to send 500 requests!!

That's normal. Typically, you need to query all pages only if you are trying to make some local mirror of TMDB dataset and in this case you can wait a while for all pages to download. You can use more download threads if you need to speed things up.

@talestalker thanks, could you give me a hint how to query all pages? I'm kinda new at this things

@bcourtine that's not fun!

could you give me a hint how to query all pages?

You must make 500 separate queries. But it really isn't that bad, as it takes just ~70 seconds to download all 500 pages with one thread and ~4 seconds using 32 threads.

#Simple python solution to do this
df = pd.DataFrame(
for i in range(1,500):
        url = f'https://api.themoviedb.org/3/discover/movie?include_adult=false&include_video=false&language=en-US&page={i}&sort_by=popularity.desc&api_key={api_key}'
        response = requests.get(url)
        temporary_df = pd.DataFrame(response.json()['results'])
        df = pd.concat([df,temporary_df],ignore_index=True)

HEY HOW DO I KNOW THE TOTAL NUMBER OF PAGES AVALIAVLE?

You are getting the total number of pages in every response to discover method:

{
  "page": 1,
  "results": [
   ...
  ],
  "total_pages": 38808,
  "total_results": 776151
}

You can query only first 500 pages, though.

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