Skip to main content

A collection of Shopify utilities to make life easier.

Project description

turtlefy

              _,.---.---.---.--.._
            _.-' `--.`---.`---'-. _,`--.._
           /`--._ .'.     `.     `,`-.`-._\
          ||   \  `.`---.__`__..-`. ,'`-._/
     _  ,`\ `-._\   \    `.    `_.-`-._,``-.
  ,`   `-_ \/ `-.`--.\    _\_.-'\__.-`-.`-._`.
 (_.o> ,--. `._/'--.-`,--`  \_.-'       \`-._ \
  `---'    `._ `---._/__,----`           `-. `-\
            /_, ,  _..-'                    `-._\
            \_, \/ ._(
             \_, \/ ._\
              `._,\/ ._\
                `._// ./`-._
                  `-._-_-_.-'

A collection of Shopify utilities to make life easier.

Sometimes you just want to get things done in a straightforward and lightweight manner.

Like pulling all your Shopify orders into a list so you can do stuff with them.

Instead of reading all the API docs on how to paginate your orders, or customers, products etc, just use the recursive function and you've got your list. Now do stuff.

Usage:

from turtlefy.client import get_turtlefy_client
from turtlefy.resources import get_all_resources

client = get_turtlefy_client('https://base.myshopify.com', token='xxxx')

order_uri = f'{client.api_path}/orders.json'

orders = get_all_resources(client, order_uri, resource_type='orders')

len(orders) >> 50

In addition, you can use the get_all_resources_iter function like this:

from turtlefy.resources import get_all_resources_iter

# Note that using limit=1 is very inefficient, but you can
# yield one resource at a time this way
customer_uri = f'{client.api_path}/customers.json?limit=1'

for customer in get_all_resources_iter(client, customer_uri, resource_type='customer'):
    print(customer)

order_uri = f'{client.api_path}/orders.json?limit=250'

for orders in get_all_resources_iter(client, order_uri, resource_type='orders'):
    print(f'Got {len(orders)} orders')

Automatic Rate Limiting:

Also, some little goodies include automatic rate limit detection. Shopify uses a "leaky bucket algorithm" to determine when to start rate limiting your requests.

https://shopify.dev/concepts/about-apis/rate-limits

Normally you would need to write some detection and backoff code in order to pull a bunch of resources without hitting limits. With the Turtlefy client you can just get all the resources and the client will handle the rate limit backoff.

NOTE: Currently this uses a very naive halving of the bucket leak count. This will be getting a better, and proper exponential backoff capability in the near future.

What's with the name? It's turtles all the way down!

https://en.m.wikipedia.org/wiki/Turtles_all_the_way_down

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

turtlefy-0.8.12.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

turtlefy-0.8.12-py2.py3-none-any.whl (7.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file turtlefy-0.8.12.tar.gz.

File metadata

  • Download URL: turtlefy-0.8.12.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for turtlefy-0.8.12.tar.gz
Algorithm Hash digest
SHA256 2395c94adbf7f175864025d3f38232ffbf67af7f831dadb72398e62441ebb644
MD5 c4b72463ab7bdee5bf6a6f948bede97e
BLAKE2b-256 d3454570aef7051e3b422d3be7a3394c317ca7af9d82e0852e91e2859b8b830a

See more details on using hashes here.

File details

Details for the file turtlefy-0.8.12-py2.py3-none-any.whl.

File metadata

  • Download URL: turtlefy-0.8.12-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for turtlefy-0.8.12-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 09d4d5993adf2d38970f1769b55688c031d9383fc13ef0a8a5b0cab450564373
MD5 5b16732b7989c8543bb661ce008c2c29
BLAKE2b-256 df0b03e4de1e71c1ab49ca1202a0b1141c8a6c005bdd2fddaf3427467b741e14

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page