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.6.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

turtlefy-0.6.0-py2.py3-none-any.whl (6.5 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: turtlefy-0.6.0.tar.gz
  • Upload date:
  • Size: 7.4 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.6.0.tar.gz
Algorithm Hash digest
SHA256 8c39bee57ce6433c181d4dcd77b815fec0a7a3efc068144c9743ba3e0bf8e6dd
MD5 a5c5448b59c20bad3ec106aef855a75e
BLAKE2b-256 369d58b87906261d5bef6db42290e16c8a83df844f57d77161fcdb81a626d354

See more details on using hashes here.

File details

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

File metadata

  • Download URL: turtlefy-0.6.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.5 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.6.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8d4acc686dc88faceb1fb10eeec005fb39f08c4a4c393630e9c01991e46c831e
MD5 460bf752573b5304ab97881456bafb10
BLAKE2b-256 2ecc2ffadf155642cf8165e83ec0ddf70acbd4fdfd35e4180d912241398f3b10

See more details on using hashes here.

Supported by

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