Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
How to ignore Execution time of Google script and JS

I have for loop here for calling API calls from ticketmaster website and import in google sheets. The problem is I can't make many API calls at once I have to wait about 1 second.

So when I make the loop wait 1 second for example if the array has 40 element I wait 40 sec. No problem with that due to the massive data but when the fucntion wait it gives an error of execution time limit, I need to set the execution time unlimited.

for (var Veunue_id1 = 0; Veunue_id1 < Venue_Id_List.length; Veunue_id1++) {


  var Venue_API_Url = "https://app.ticketmaster.com/discovery/v2/venues?apikey=" + API_key + "&keyword=" + Venue_Id_List[Veunue_id1] + "&locale=*";


  // ImportJSON(url, "/","noInherit,noTruncate,rawHeaders");
  // console.log(ImportJSON(url, "/", "noInherit,noTruncate,rawHeaders"));

  //  console.log("Veuneid" + Veunue_id + Venue_Id_List.length);
  

  results = results.concat(ImportJSON(Venue_API_Url, "/_embedded/venues/id", "noInherit,noTruncate,rawHeaders"));
  console.log(results);

// wait1 second
 Utilities.sleep(1000);



}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This a common issue, especially when working with heavy data API. General approach is:

  1. Run as much as you can, until timeout(6 min) is close
  2. Save loaded data
  3. Store some indicator on there to resume on next run
  4. On next run, repeat from position saved in 3)
  5. Put this on trigger.

Example code based on your situation (not tested)

function SimpleTimer(timeout){
  var start = Date.now();
  this.getElapsed = () => Date.now() - start;
  this.isTimeout = () => this.getElapsed() > timeout;  
}

function resetProgress(){
  PropertiesService.getScriptProperties().setProperty('last', '-1')
}

function test_SimpleTimer() {
  var timer = new SimpleTimer(4*60*1000) // 4 min;

  var start = PropertiesService.getScriptProperties().getProperty('last') || '-1';

  for (var Veunue_id1 = parseInt(start) + 1; Veunue_id1 < Venue_Id_List.length && ! timer.isTimeout(); Veunue_id1++) {
    var Venue_API_Url = "https://app.ticketmaster.com/discovery/v2/venues?apikey=" + API_key + "&keyword=" + Venue_Id_List[Veunue_id1] + "&locale=*";       

    results = results.concat(ImportJSON(Venue_API_Url, "/_embedded/venues/id", "noInherit,noTruncate,rawHeaders"));

    Utilities.sleep(1000);
    PropertiesService.getScriptProperties().setProperty('last', '' + Veunue_id1)
  }
    // SAVE YOUR DATA HERE, NEXT CALL WILL PROCEED FROM LAST STEP

}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!