Last Updated: February 25, 2016
· mrkschan

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 - To do so, download Cuttle and use the config below:

# Download
GOPATH=`pwd` go get

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

And, run it.

bin/cuttle -f cuttle.yml

Then, make API calls like below:

import shopify

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

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

# Run