#[1]gnikyt feed [2]gnikyt / Code ramblings [3]Ty King [4]About[5]Github[6]LinkedIn[7]CV[8]RSS Async Shopify API for Python / [9]Logo of shopify [10]Logo of python Introduction I maintain a fairly used [11]PHP library for Shopify API which uses Guzzle for sync/async requests. It was also recently featured as a recommended third-party library on Shopify's dev docs. For Python, which I also use with Shopify work, I didn't notice a library which provides async abilities. Normally I use Shopify's Python library which provides a nice ActiveResource implementation. However, their library has no plans to support async. I decided to create a tested library that can do both, [12]basic_shopify_api. It is a loose port of my PHP version which supports sync, async, HMAC validation, rate limiting, automatic retries, REST, and GraphQL; all backed by the HTTPX package. You simply need to set up some basic options and create a session for a shop to get started. Sync REST from basic_shopify_api import Client # ... with Client(sess, opts) as client: shop = client.rest("get", "/admin/api/shop.json", {"fields": "name,email"}) print(shop.response) print(shop.body["name"]) # returns the following: # RestResult( # response=The HTTPX response object, # body=A dict of JSON response, or None if errors, # errors=A dict of error response (if possible), or None for no errors, or the exception error, # status=The HTTP status code, # link=A RestLink object of next/previous pagination info, # retries=Number of retires for the request # ) GraphQL from basic_shopify_api import Client # ... with Client(sess, opts) as client: shop = client.graphql("{ shop { name } }") print(shop.response) print(shop.body["data"]["shop"]["name"]) # returns the following: # ApiResult( # response=The HTTPX response object, # body=A dict of JSON response, or None if errors, # errors=A dict of error response (if possible), or None for no errors, or the exception error, # status=The HTTP status code, # retries=Number of retires for the request, # ) Async REST from basic_shopify_api import AsyncClient # ... async with AsyncClient(sess, opts) as client: shop = await client.rest("get", "/admin/api/shop.json", {"fields": "name,ema il"}) print(shop.response) print(shop.body["name"]) # returns the following: # RestResult( # response=The HTTPX response object, # body=A dict of JSON response, or None if errors, # errors=A dict of error response (if possible), or None for no errors, or the exception error, # status=The HTTP status code, # link=A RestLink object of next/previous pagination info, # retries=Number of retires for the request # ) GraphQL from basic_shopify_api import AsyncClient # ... async with AsyncClient(sess, opts) as client: shop = await client.graphql("{ shop { name } }") print(shop.response) print(shop.body["data"]["shop"]["name"]) # returns the following: # ApiResult( # response=The HTTPX response object, # body=A dict of JSON response, or None if errors, # errors=A dict of error response (if possible), or None for no errors, or the exception error, # status=The HTTP status code, # retries=Number of retires for the request, # ) Conclusion The above examples are brief, refer to the README of the project for full information. But I believe you will find it very helpful - especially the automatic retries for failed requests and built-in rate/cost limiting. Feel free to give it a try with your projects, with the continual rise of async within Python, I hope the library will serve some use to you. I've recently paired it with [13]FastAPI and it performed well. Anchors * [1] [14]github.com/gnikyt/Basic-Shopify-API /^ * [2] [15]github.com/gnikyt/basic_shopify_api /^ * [3] [16]fastapi.tiangolo.com/ /^ Appendix This post is 5 years old and may contain outdated information. Copyright under [17]CC-4.0. Available in the following alternative formats: [18]MD / [19]TXT / [20]PDF * * * * * * * * References 1. /rss.xml 2. file:/// 3. file:///about 4. file:///about 5. https://github.com/gnikyt 6. https://linkedin.com/in/gnikyt 7. file:///assets/files/cv.pdf 8. file:///rss.xml 9. file:///category/shopify 10. file:///category/python 11. https://github.com/gnikyt/Basic-Shopify-API 12. https://github.com/gnikyt/basic_shopify_api 13. https://fastapi.tiangolo.com/ 14. https://github.com/gnikyt/Basic-Shopify-API 15. https://github.com/gnikyt/basic_shopify_api 16. https://fastapi.tiangolo.com/ 17. https://creativecommons.org/licenses/by/4.0/ 18. file:///async-shopify-api-for-python/index.md 19. file:///async-shopify-api-for-python/index.txt 20. file:///tmp/lynxXXXXLR7hI3/L7816-9803TMP.html