Last Updated: February 25, 2016
· mrkschan
241583 10150247151724974 30598 o square

Rate limiting Shopify API using Cuttle Proxy

We can use sleep() to rate limit our calls to Shopify API. When we need to rate limit calls in multiple processes, sleep() does not work well enough.

In that case, we may use a HTTP proxy with outbound rate limit capability - https://github.com/mrkschan/cuttle. To do so, download Cuttle and use the config below:

# Download
GOPATH=`pwd` go get github.com/mrkschan/cuttle

# Config - cuttle.yml
addr: :3128
  - host: "*.myshopify.com"
    shared: false
    control: rps
    rate: 3

And, run it.

bin/cuttle -f cuttle.yml

Then, make API calls like below:

# client.py
import shopify

shop_url = 'https://{}:{}@{}/admin'.format(API_KEY, PASSWORD, SHOPIFY_DOMAIN)

print json.dumps(shopify.Shop.current().to_dict())

# Run
HTTPS_PROXY= python client.py
Say Thanks