How to get more than 10 search results from the IMDB API?
Question:
I am trying to suggest movies to an user who has entered a movie genre, e.g. "horror", "sci-fi", etc.
For this, I have written a function that makes an API call towards the IMDB API:
import requests
def search_movies(search, api_key):
movies = []
url = "https://imdb-api.com/API/SearchMovie/"+api_key+"/"+search
response = requests.get(url)
data = response.json()
results = data['results']
for result in results:
movies.append(result['title'])
return(movies)
The API only returns 10 search results, which is not enough for what I am trying to achieve. Is there a way to increase this number? I was unable to find any parameters for this on Swagger, and pagination also doesn’t seem to be an option, as the request is not made via URL parameters.
Answers:
I don’t think you can get more results from that unofficial web service.
I believe it is better to use the official IMDb API as stated on the official website.
From the IMDb developer website:
Get the latest IMDb data on-demand through our new GraphQL-backed API. Available exclusively via AWS Data Exchange
You can use AdvancedSearch, which returns up to 250 items.
https://imdb-api.com/api#AdvancedSearch-header
Sample:
https://imdb-api.com/API/AdvancedSearch/{API_KEY}?title={TITLE_FOR_SEARCH}&count=250
https://imdb-api.com/API/AdvancedSearch/{API_KEY}?title={TITLE_FOR_SEARCH}&title_type=tv_series&genres=action,adventure&count=250
You should try features of PyMovieDb, It is a free python module for IMDB
I am trying to suggest movies to an user who has entered a movie genre, e.g. "horror", "sci-fi", etc.
For this, I have written a function that makes an API call towards the IMDB API:
import requests
def search_movies(search, api_key):
movies = []
url = "https://imdb-api.com/API/SearchMovie/"+api_key+"/"+search
response = requests.get(url)
data = response.json()
results = data['results']
for result in results:
movies.append(result['title'])
return(movies)
The API only returns 10 search results, which is not enough for what I am trying to achieve. Is there a way to increase this number? I was unable to find any parameters for this on Swagger, and pagination also doesn’t seem to be an option, as the request is not made via URL parameters.
I don’t think you can get more results from that unofficial web service.
I believe it is better to use the official IMDb API as stated on the official website.
From the IMDb developer website:
Get the latest IMDb data on-demand through our new GraphQL-backed API. Available exclusively via AWS Data Exchange
You can use AdvancedSearch, which returns up to 250 items.
https://imdb-api.com/api#AdvancedSearch-header
Sample:
https://imdb-api.com/API/AdvancedSearch/{API_KEY}?title={TITLE_FOR_SEARCH}&count=250
https://imdb-api.com/API/AdvancedSearch/{API_KEY}?title={TITLE_FOR_SEARCH}&title_type=tv_series&genres=action,adventure&count=250
You should try features of PyMovieDb, It is a free python module for IMDB