Sleep for API call limit is not working

Our package support 600 API calls per minute. However, I need to run a for loop for 1000 times and save objects to table. I am getting API call limit error message when I ran around 600 times. So I used sleep method in PHP. But that did not work


foreach($questions as $question)
{
    if($request > 560){
      sleep(70);
      $request = 0;
    }
    
    Backendless::$Persistence->of('Category')->save($question->category);
    $request = $request + 1;  
  }

Hi Krish,

This is purely a PHP-related problem, and unfortunately our team is no expert in PHP. You should better ask for the advice on any specialized PHP forum or on StackOverflow.
And in case you run into any problem related to Backendless API - then please feel free to report it on our support forum.
Best regards,
Sergey

Other than increase the plan, is this the best way to handle API limit? Or is there are any other ways we can handle?

The rate limiting strategy like the one you tried is probably the most straight-forward way to handle the limit. Another one is to catch the “API call limit reached” error and retry the request after some delay.