Understanding Rate Limits in the Shopify REST Admin API

Alexa Hyde
Broadlume Product Development
3 min readAug 19, 2020

I recently had a project that involved taking a number of products from a source and uploading them to Shopify. This is certainly something you can do with Shopify — the Shopify API is powerful and it provides endpoints for creating, updating, and deleting products. But I ended up running into trouble with Shopify’s rate limits, especially since they’re set up in a way that can be a little confusing.

As a disclaimer, I’m specifically talking about the Shopify REST Admin API here. Rate limiting for the Storefront and GraphQL APIs use different methods: the Storefront API is based on how long it takes requests to resolve and the GraphQL API is based on a points system. The REST API is, at its core, based on the number of requests within a time period, but there’s a bit of complexity on top of that.

The Leaky Bucket Algorithm

Shopify uses what’s known as a leaky bucket algorithm for handling requests, and the easiest metaphor to explain it is the one in the name. Imagine that every time you make a request to Shopify, it’s put into a bucket. This bucket has a fixed capacity (40 requests for Shopify) and as long as you don’t fill the bucket all the way up, you can keep putting requests into the bucket with no problem.

There’s a small hole in the bottom of the bucket, which allows requests to slowly leak out (at a rate of 2 requests per second for Shopify). Once they’ve leaked out from that hole they are resolved.

Like that but only one hole.

This means that you can make bursts of requests without worrying about the rate limit as long you stay within the bucket’s total capacity. If you make 20 requests simultaneously, they’ll be added to the bucket and resolved at a rate of 2 per second and you don’t have to worry about rate limits at all.

It’s when you’re making more than 40 requests in one go and hitting the limit, that you need to start being careful. If you try to add another request to the bucket when it’s reached capacity, you’ll get a 429 TOO MANY REQUESTS error code back.

You can wait half a second for a space to open up and then make the request again, but from that point onwards the bucket no longer helps you. You are tied to the strict 2 requests per second limit and avoiding going over that is now your responsibility.

Practical Takeaways

If you are making only a few requests (i.e. less than 40) go ahead and make all your requests at once. The bucket will insulate your requests against the rate limit.

If you are making a lot of requests (i.e more than 40) only make 2 requests per second. If you’d like, you could factor in the bucket by making 40 requests simultaneously and after that waiting. But the increase in speed you’d get is pretty marginal and (in my opinion) not worth your time.

Powered by the Shopify API

My project had the potential for making hundreds of updates so I ended up ignoring the bucket and putting a second’s wait between each product upload. This was more than enough to insulate the project from any rate limit worries.

You can read more about Shopify’s approach to rate limiting for any other APIs in their documentation. That’s also where I’d go if you found this article looking for advice about Shopify APIs other than the REST Admin. As long as you keep an eye on the rate limit, you can take advantage of the full power of the Shopify API for whatever apps you want to make.

--

--