Re: Script Block populating Airtable from external RESTful API, based on existing rows

1489 0
Showing results for 
Search instead for 
Did you mean: 
7 - App Architect
7 - App Architect

An extension of Example: Netflix-style UI with a script, here we use OMDB API in the Scripting Block, to grab the Runtime/Duration of a given film from a given Airtable: (1)

Could of course be used with any API service, with a bit of adapting.


  • add a max_count so that it doesn’t hit the API’s rate limits e.g. simply change line 20 to
    for (let record of result.records.slice(0,1000)) {
  • add error handling (currently, if film is not found, the script simply skips to the next row).
5 Replies 5
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi Oli. Thank you so much for this script. Using this and the Netflix-style script to make my first steps with the scripts section (I have no background in programming, so this is all very learning by doing).

I was just wondering: can I use this also to call the RottenTomatoes score? I know how to make this work with simple values like Runtime, but does anyone know how to get the script to pick the Rottentomatoes Value from the ‘Ratings’ section of the OMDB API?

"Ratings":[{"Source":"Internet Movie Database","Value":"7.4/10"},{"Source":"Rotten Tomatoes","Value":"98%"},{"Source":"Metacritic","Value":"99/100"}],"Metascore":"99","imdbRating":"7.4","imdbVotes":"253,485","imdbID":"tt4975722",

Sorry if this question is a bit basic… these are my first baby steps working with these kind of scripts :slightly_smiling_face:

Sure I have this in a script I can paste later today (2-3hr from now)

Wow, thank you! That would be amazing!

7 - App Architect
7 - App Architect

@MarvinW visit any webpage using Chrome, open DevTools (CtrlShiftC/CmdShiftC), click Console section, then paste in this code (with your own OMDB API key). It should demo the ratings nesting nicely. I used it in a first draft of this site I’m building which uses Airtable API for all its data

var myKey = [your OMDB API key];
var myFilm = "tt1285016";
var myRequest = "" +
                "?apikey=" + myKey + 
                "&i=" + myFilm;
console.log("about to request from " + myRequest);
  .then((myResponse) => myResponse.json())
  .then((myJson) => {
    document.write("<h1>" + myJson['Title'] + "</h1>");
    var keys = Object.keys(myJson["Ratings"]);
    for (const key of keys) {
      // uncomment 2x lines to filter for ONLY Rotten Toms...
      // if (myJson["Ratings"][key]["Source"] == "Rotten Tomatoes"){ // this one
      console.log("ratings: " + myJson['Ratings'][key])
      "<p>" +
      myJson["Ratings"][key]["Source"] +
      ": <strong>" +
      myJson["Ratings"][key]["Value"] +
      // } // and this one!
7 - App Architect
7 - App Architect

@MarvinW I think I misunderstood you, sorry my answer didn’t go in the right direction. I’m actually looking to solve the Same question you’ve posed and wanted to ask: any solution found? I’ve tried a couple different approaches (nesting via await async, and via fetch/promise) and neither is working. Very interested to know how you solved it.