how to slow down API calls in ruby script on Amazon Product API

122 views Asked by At

Ruby Script:

I am dealing with a rate limit on the order of 1 request per second. How can I slow my script down so I don't receive errors?

Update: It was suggested I use Kernel [sleep][1]

I attempted to implement as follows: (Where Items is a table in the database)

  Item.limit(10000).each do |item|

  sleep(1)

  //Make API Call Here

  end 

I think it's working!

1

There are 1 answers

4
Roman Kiselenko On BEST ANSWER

You alway can use Kernel#sleep.