Rate Limit Challenges

countablecountable Posts: 3Member

Hi lightspeed devs!

I'm wondering if anyone else has had trouble with rate limiting. I've built a price updating bot that has to make 15,000 API calls. I've spaced them 5 seconds apart but I still occasionally get this message "Rate Limit Exceeded: Please decrease your request volume. To eliminate this message, keep your request rate below 1 requests per second. Clients that continue to receive this response may have their traffic throttled."

It's quite inconsistent, and will sometimes run fine for an hour, sync a few hundreds items, and then randomly start failing with this message.

It seems like I may have already been "throttled". If so, is there a way to recover from this state?

3 comments

  • gregaricangregarican  Posts: 311Member 

    You have to read the header values coming back in the API response. It will contain specifics as to how your API consumer is stacking against the limits. This is referred to here --> https://community.lightspeedhq.com/en/discussion/28/best-practices.

    In my environment I just time my routines against worst-case. So I make API GET requests at a rate of one request per second. And make API PUT and POST requests at a rate of one request every 10 seconds. This makes integrations very slow to say the least, but at least they are working. I could build in logic to dynamically adjust requests based on the response headers, and build in a retry subroutine. But need to move onto other matters :)


    It's a shame that you cannot PUT and POST pages of records like you can do with GET requests. Being able to insert or update records in 100 item pages like how you can GET them would be nice!

  • damonjcdamonjc Posts: 2Member

    If anyone is interested, I've built rate-limit retry code in Node.js for several different Retail API endpoints.

  • countablecountable Posts: 3Member

    Thanks @gregarican , good to know about the headers!

    @damonjc I ended up doing the same (retrying on failure, which is rare when I call once every 2s), but in Python rather than Node.

Sign In or Register to comment.