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!
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)
| File | Size | Uploaded | |
|---|---|---|---|
| turtlefy-0.8.12.tar.gz | 8.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|