Shopify enforces API rate limits to ensure stability and fair usage across all merchants. These limits control how many API requests your app can make within a given timeframe, and Shopify utilizes the "leaky bucket" algorithm to manage these limits.
Rate Limits Based on Subscription Plan
Shopify adjusts API rate limits according to the merchant's subscription plan. Higher-tier plans, such as Shopify Plus, offer increased rate limits, allowing for more API requests per second. For detailed information on how rate limits vary by plan, refer to Shopify's official documentation on API rate limits.
How Shopify's Rate Limit Works (Leaky Bucket Algorithm)
Shopify employs a leaky bucket algorithm, which can be visualized as follows:
- Imagine a bucket representing your allowed API calls.
- The bucket leaks at a steady rate, allowing space for new requests to be added over time.
- If you make requests too rapidly, your bucket can overflow, triggering a temporary limit.
Key Details
- Standard API Rate Limit: 2 requests per second (sustained)
- Burst Limits: Allows up to 40 requests in a short burst.
- The bucket has a maximum capacity of 40 requests. Each request fills the bucket by 1 request.
- Requests "leak" out of the bucket at a consistent rate of 2 requests per second.
Example of the Leaky Bucket in Action
- You begin with an empty bucket (0/40).
- Immediately send 30 requests: the bucket now holds 30/40.
- Wait 5 seconds, the bucket leaks at 2 requests per second (total of 10 requests leaked), leaving 20/40 requests in the bucket.
- You can now send up to 20 more requests immediately without hitting the limit.
If you exceed these limits, Shopify returns an HTTP status code 429 (Too Many Requests), requiring your application to wait before retrying.
Best Practices to Manage Limits
- Use rate-limiting headers returned by Shopify (
X-Shopify-Shop-Api-Call-Limit
) to track usage. - Implement retry mechanisms with exponential back-off.
- Monitor API usage proactively to avoid reaching limits.
Additional Information
For detailed information, see Shopify's official documentation on API rate limits.