The Movie Database Support

I have a list of 500+ movies and currently I'm making a new API call for each movie.

const getMovie = async (tmdbId, apiKey) => {
    const url = `https://api.themoviedb.org/3/movie/${tmdbId}?api_key=${apiKey}&append_to_response=credits,release_dates`;
    const response = await fetch(url);
    const data = await response.json();
    return data;
};

The above getMovie function is being called for every single movie in my list. I was wondering if there is a way to get the data for several movies by, for instance, comma separating their TMDB IDs and making a single API call for more than one movie at a time.

To give you an example, Spotify offers a getAlbum service which returns the catalog information for a single album. It can be accessed as follows:

const getAlbum = async (albumID, accessToken) => {
    const url = `https://api.spotify.com/v1/albums/${albumID}?market=US`;
    const headers = { Authorization: `Bearer ${accessToken}` };
    const options = { method: 'GET', headers };
    const response = await fetch(url, options);
    const data = await response.json();
    return data;
};

However, Spotify also offers a getSeveralAlbums service which returns the catalog information for a maximum of 20 Albums at a time. It can be accessed as follows:

const getSeveralAlbums = async (albumIDs, accessToken) => {
    const albumIDsStr = albumIDs.slice(0, 20).join(',');
    const url = `https://api.spotify.com/v1/albums?ids=${albumIDsStr}&market=US`;
    const headers =  { Authorization: `Bearer ${accessToken}` };
    const options = { method: 'GET', headers };
    const response = await fetch(url, options);
    const data = await response.json();
    return data;
};

In the above function, albumIDsStr is a comma separated list of several Spotify IDs, e.g. 3mH6qwIy9crq0I9YQbOuDf,0k7ALIqqds5oGFtpMsaHLK,5HOHne1wzItQlIYmLXLYfZ etc. thus reducing the number of API calls required by 20x (since Spotify only allows a maximum of 20 albums per fetch request).

Any assistance would be much appreciated! Have a good day.

2 replies (on page 1 of 1)

Jump to last post

Hi @ragonscreen,

While this is not possible at this time, we do already have a ticket for tracking this request here. You can watch/vote for it.

Cheers.

@travisbell Thank you so much for your reply, I will definitely be checking out the tracking request. Have a great day!

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