Skip to main content

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

Release files for turtlefy 0.8.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for turtlefy 0.8.12
File Size Uploaded
turtlefy-0.8.12.tar.gz 8.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for turtlefy 0.8.12
File Interpreter ABI Platform
turtlefy-0.8.12-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 15.3 kB

Release files / turtlefy-0.8.12.tar.gz

Download URL turtlefy-0.8.12.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2395c94adbf7f175864025d3f38232ffbf67af7f831dadb72398e62441ebb644
BLAKE2b-256 checksum
How to use checksums
d3454570aef7051e3b422d3be7a3394c317ca7af9d82e0852e91e2859b8b830a
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / turtlefy-0.8.12-py2.py3-none-any.whl

Download URL turtlefy-0.8.12-py2.py3-none-any.whl
Size 7.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
09d4d5993adf2d38970f1769b55688c031d9383fc13ef0a8a5b0cab450564373
BLAKE2b-256 checksum
How to use checksums
df0b03e4de1e71c1ab49ca1202a0b1141c8a6c005bdd2fddaf3427467b741e14
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.8.12 This release

2 release files

0.8.11

2 release files

0.8.10

2 release files

0.8.9

2 release files

0.8.8

2 release files

0.8.7

2 release files

0.8.6

2 release files

0.8.5

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page