How to integrate IMDB API through RapidAPI with Google Sheets for movie data retrieval

Setting up IMDB API in Google Sheets

I’m trying to build my first API project and want to pull movie details into a Google Sheet using the movie title as input. I found RapidAPI has a Google Sheets extension but I’m struggling with the implementation.

Current Understanding

I found one working example using the =GET() function for stock data:

=GET("https://financial-data-api.p.rapidapi.com/stocks/{ticker}/details","info.name","API_KEY_PLACEHOLDER","ticker","MSFT")

This example doesn’t work for me, and the IMDB API documentation shows a different structure. I’m confused about the {ticker} placeholder syntax.

The IMDB API sample code looks like this:

const fetch = require("node-fetch");

const settings = {
  method: 'GET',
  url: 'https://movie-database-imdb.p.rapidapi.com/search/title',
  params: {query: 'Inception'},
  headers: {
    'x-rapidapi-host': 'movie-database-imdb.p.rapidapi.com',
    'x-rapidapi-key': 'abc123def456ghi789jkl012mno345pqr678stu901vwx234'
  }
};

fetch(settings).then(function (result) {
    console.log(result.data);
}).catch(function (err) {
    console.error(err);
});

When I search IMDB manually, the URL structure is:

https://www.imdb.com/find?query=inception&ref_=nv_sr_sm

I notice the query parameter which seems relevant.

Main Issues

  • How should I structure the =GET() function for IMDB data?
  • What do the curly braces mean in the URL?
  • Every attempt gives me this error:

Error: Request failed for https://movie-database-imdb.p.rapidapi.com returned code 400. Bad Request (use muteHttpExceptions to see full response)

Looking for Help

Can anyone share a working example or point me to beginner-friendly documentation for this setup?

Indeed, the RapidAPI Google Sheets extension is a solid choice for your needs. I faced similar challenges when integrating movie APIs initially. The extension simplifies authentication, which is likely to eliminate those pesky 400 errors you’ve encountered. Simply install the extension and utilize a formula like =RAPIDAPI(“movie-database-imdb”, “search/title”, “query”, A2), with A2 containing your movie title. This approach automatically handles API keys and headers, making it far more dependable than crafting requests manually, particularly given RapidAPI’s specific authentication needs.

u got it! That 400 error often pops up when the needed headers ain’t set up correctly. Try using UrlFetchApp.fetch() in Apps Script for your IMDB query, it should work smoother. Good luck with your project!

Those curly braces are URL path parameters that get replaced dynamically, but Google Sheets’ GET function can’t handle this syntax. You’ll need to build the full URL with query parameters instead. For the IMDB API, skip the simple GET function and use Apps Script: function getMovieData(movieTitle) { const url = ‘https://movie-database-imdb.p.rapidapi.com/search/title?query=’ + encodeURIComponent(movieTitle); const options = { ‘method’: ‘GET’, ‘headers’: { ‘x-rapidapi-host’: ‘movie-database-imdb.p.rapidapi.com’, ‘x-rapidapi-key’: ‘your_actual_key_here’ } }; const response = UrlFetchApp.fetch(url, options); return JSON.parse(response.getContentText()); } That 400 error means you’re missing or have wrong headers. RapidAPI needs specific headers that the basic GET function can’t provide. Apps Script gives you way more control over how the request is structured.