The Shopify REST Admin API applies rate limits to the API requests that it receives. Every request is subject to throttling under the general limits. The rate limits are designed to allow your app to make unlimited requests at a steady rate over time while also having the capacity to make infrequent bursts. The rate limits use a leaky bucket algorithm. The bucket size and leak rate properties determine the API's burst behavior and request rate.
The default settings are as follows:
- Bucket size: 40
- Leak rate: 2/second
If the bucket size is exceeded, then an HTTP 429 Too Many Requests
error is returned.
Recommendations
- Design your app with API rate limits in mind to best handle request limits and avoid 429 errors.
- Stagger API requests in a queue and do other processing tasks while waiting for the next queued job to run.
Use the rate limits header to balance your request volume.
We handled this use case using celery. Basically, you need to make API calls and whenever a call fails you get an exception code. If the code is 429 then you retry the same task in an interval(below check how to get the interval) till it is successful.
How to get the interval after which you can make a request after your app is throttled?
If your app is throttled, then it won't be able to make any more requests until enough time has passed and your bucket has capacity again. You can calculate this wait time manually using the bucket size and leak rate properties, or by using the Retry-After
response header
Source: Shopify Rate Limit Documentation