turtlefy


Nameturtlefy JSON
Version 0.8.8 PyPI version JSON
download
home_pagehttps://github.com/nprutan/turtlefy
SummaryA collection of Shopify utilities to make life easier.
upload_time2020-08-06 23:03:14
maintainer
docs_urlNone
authorNate Rutan
requires_python>=3.7.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# 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:

```python
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:

```python
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




            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/nprutan/turtlefy",
    "name": "turtlefy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Nate Rutan",
    "author_email": "nathan@composedcloud.com",
    "download_url": "https://files.pythonhosted.org/packages/6f/97/55fa8f95183096f477381dc84fed6b9ce538275d7c8e3567b16f994d21dc/turtlefy-0.8.8.tar.gz",
    "platform": "",
    "description": "\n# turtlefy\n```\n              _,.---.---.---.--.._\n            _.-' `--.`---.`---'-. _,`--.._\n           /`--._ .'.     `.     `,`-.`-._\\\n          ||   \\  `.`---.__`__..-`. ,'`-._/\n     _  ,`\\ `-._\\   \\    `.    `_.-`-._,``-.\n  ,`   `-_ \\/ `-.`--.\\    _\\_.-'\\__.-`-.`-._`.\n (_.o> ,--. `._/'--.-`,--`  \\_.-'       \\`-._ \\\n  `---'    `._ `---._/__,----`           `-. `-\\\n            /_, ,  _..-'                    `-._\\\n            \\_, \\/ ._(\n             \\_, \\/ ._\\\n              `._,\\/ ._\\\n                `._// ./`-._\n                  `-._-_-_.-'\n```\n\nA collection of Shopify utilities to make life easier.\n\nSometimes you just want to get things done in a straightforward\nand lightweight manner.\n\nLike pulling all your Shopify orders into a list so you\ncan do stuff with them.\n\nInstead of reading all the API docs on how to paginate your\norders, or customers, products etc, just use the recursive\nfunction and you've got your list. Now do stuff.\n\n## Usage:\n\n```python\nfrom turtlefy.client import get_turtlefy_client\nfrom turtlefy.resources import get_all_resources\n\nclient = get_turtlefy_client('https://base.myshopify.com', token='xxxx')\n\norder_uri = f'{client.api_path}/orders.json'\n\norders = get_all_resources(client, order_uri, resource_type='orders')\n\nlen(orders) >> 50\n```\n\nIn addition, you can use the get_all_resources_iter function like this:\n\n```python\nfrom turtlefy.resources import get_all_resources_iter\n\n# Note that using limit=1 is very inefficient, but you can\n# yield one resource at a time this way\ncustomer_uri = f'{client.api_path}/customers.json?limit=1'\n\nfor customer in get_all_resources_iter(client, customer_uri, resource_type='customer'):\n    print(customer)\n\norder_uri = f'{client.api_path}/orders.json?limit=250'\n\nfor orders in get_all_resources_iter(client, order_uri, resource_type='orders'):\n    print(f'Got {len(orders)} orders')\n\n```\n\n## Automatic Rate Limiting:\n\nAlso, some little goodies include automatic rate limit detection.\nShopify uses a \"leaky bucket algorithm\" to determine when to start\nrate limiting your requests.\n\nhttps://shopify.dev/concepts/about-apis/rate-limits\n\nNormally you would need to write some detection and backoff code in order to\npull a bunch of resources without hitting limits. With the Turtlefy client you\ncan just get all the resources and the client will handle the rate limit\nbackoff.\n\nNOTE: Currently this uses a very naive halving of the bucket leak\ncount. This will be getting a better, and proper exponential backoff\ncapability in the near future.\n\nWhat's with the name? It's turtles all the way down!\n\nhttps://en.m.wikipedia.org/wiki/Turtles_all_the_way_down\n\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A collection of Shopify utilities to make life easier.",
    "version": "0.8.8",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "e771fa8d33ccb12a30fbab5b053454c6",
                "sha256": "4780381c7fbda789f63460846061cbd0fe9d39714f20de37e6bab638341c5341"
            },
            "downloads": -1,
            "filename": "turtlefy-0.8.8-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e771fa8d33ccb12a30fbab5b053454c6",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.7.0",
            "size": 7025,
            "upload_time": "2020-08-06T23:03:12",
            "upload_time_iso_8601": "2020-08-06T23:03:12.703458Z",
            "url": "https://files.pythonhosted.org/packages/fe/e9/b8e534e71b6988e2e9e0eeb9b98acc304d66075912c3d9526fd411413e14/turtlefy-0.8.8-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "cbc33975f1ba779609b997580260e0fd",
                "sha256": "09e19eb8a93310273184ae942772c26a117aee2592df6370f935e6f136c9a9b2"
            },
            "downloads": -1,
            "filename": "turtlefy-0.8.8.tar.gz",
            "has_sig": false,
            "md5_digest": "cbc33975f1ba779609b997580260e0fd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7.0",
            "size": 7916,
            "upload_time": "2020-08-06T23:03:14",
            "upload_time_iso_8601": "2020-08-06T23:03:14.138916Z",
            "url": "https://files.pythonhosted.org/packages/6f/97/55fa8f95183096f477381dc84fed6b9ce538275d7c8e3567b16f994d21dc/turtlefy-0.8.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-08-06 23:03:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "nprutan",
    "error": "Could not fetch GitHub repository",
    "lcname": "turtlefy"
}
        
Elapsed time: 0.17477s