Rate limiting on large import

algulsientoalgulsiento Member Posts: 8
edited October 2019 in Development

I'm trying to create a set of gift cards by making the following calls:

curl -X POST -H "Authorization: Bearer $access_token" -d '{ "code":"07398687787316951208", "name":"My Groovy Gift Card", "description": "Gift Card" }' "https://api.lightspeedapp.com/API/Account/$accountID/CreditAccount.json" | jq

sleep 5

curl -X POST -H "Authorization: Bearer $access_token" -d '{ "employeeID": 1, "registerID": 1, "shopID": 1, "completed": true, "SalePayments": { "SalePayment": [ { "amount": "-100", "creditAccountID": "2", "paymentTypeID": "5" }, { "amount": "100", "paymentTypeID": "1" } ] } }' "https://api.lightspeedapp.com/API/Account/$accountID/Sale.json" | jq

sleep 5

I'm consistently getting a throttling message despite trying to put a sleep 5s between every HTTP call. Am I doing something outside the bounds of what is allowed in the API?

{"httpCode":"429","httpMessage":"Too Many Requests","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.","errorClass":"RateLimitedException"}

Post edited by algulsiento on

1 comment

  • Adrian SamuelAdrian Samuel Moderator, Lightspeed Staff Posts: 654 moderator

    Hey @algulsiento,

    The default rate limit inserts point back per second into your bucket

    It costs 10 points to do a write.

    So if you only sleep 5 seconds, you're going waiting long enough to get enough points to make another successful request hence the reason why you're receiving the error. of making too many requests.

    Instead of setting arbitrary sleeps, it would be better for you to use the Retry-After header which you get after a 429 which tells you how long to sleep for.

    More can be read about this here:


    Adrian Samuel

    Software Developer

    Lightspeed HQ

Sign In or Register to comment.