Tiny, production-minded helper for the Shopify Admin GraphQL API
Project description
Shopify GraphQL Helper
Tiny, production‑minded helpers for the Shopify Admin GraphQL API.
Shopify's official Python SDK exposes GraphQL().execute only; this
package adds sessions, automatic cursor pagination, and per‑shop
throttling.
Features:
- 🚀 Simple, focused API for Shopify GraphQL Admin API
- 🔄 Automatic cursor-based pagination
- ⚡ Built-in request throttling
- 🔒 Thread-safe implementation
- 🧩 Transport layer abstraction
Note: This is not an official Shopify package.
Installation
pip install shopify-gql-helper
Quickstart
query = """
query ($first:Int!, $after:String) {
products(first:$first, after:$after, query:"status:ACTIVE") {
pageInfo { hasNextPage endCursor }
nodes { id legacyResourceId title handle }
}
}
"""
from shopify_gql_helper import ShopifySession, execute, cursor_pages
session = ShopifySession("https://example.myshopify.com", "shpca_123")
# One-off request
data = execute(session, query, {"first": 1})
# Stream all products
for product in cursor_pages(session, query, {}, ["data", "products"]):
print(product["id"], product["title"])
connection_path lists the keys from the response root to the desired
connection, so ["data", "products"] points to data.products above.
Throttling
Shopify uses a leaky bucket policy.
ShopifySession coordinates requests per shop through a shared
ThrottleController. Adjust min_bucket (default 50) and min_sleep
(default 1.0s) to tune how aggressively you consume the bucket. Reuse a
single ShopifySession per shop to avoid fighting the throttling
limits.
Configuration
ShopifySession
from shopify_gql_helper import ShopifySession
# Required parameters
session = ShopifySession(
shop_url="https://your-store.myshopify.com",
access_token="shpca_your_access_token"
)
# Optional parameters
session = ShopifySession(
shop_url="https://your-store.myshopify.com",
access_token="shpca_your_access_token",
api_version="2025-01", # default
min_bucket=50, # minimum available requests before throttling
min_sleep=1.0, # minimum sleep time between requests (seconds)
)
Throttling
Shopify uses a leaky bucket policy.
ShopifySession coordinates requests per shop through a shared
ThrottleController.
Important: Reuse a single ShopifySession per shop to properly respect rate limits.
Custom Transport
You can provide a custom transport that implements the Transport protocol:
from shopify_gql_helper.transport import Transport
class CustomTransport(Transport):
def post(self, url: str, headers: dict, json: dict, timeout: float):
# Your custom implementation
pass
Development
# Install with development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run with coverage
pytest --cov=shopify_gql_helper
Limitations / Roadmap
- Bulk operations
- Nested pagination (e.g., products → variants)
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
This project is not affiliated with Shopify Inc. Shopify is a registered trademark of Shopify Inc.
MIT. Not affiliated with Shopify.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shopify_gql_helper-0.1.0.tar.gz.
File metadata
- Download URL: shopify_gql_helper-0.1.0.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cce7d8cf31d6fd8b4b3b5428b879bb34a940c54f75ad5fe2f0fa527736559b40
|
|
| MD5 |
a4556cf3654deef41693e6c11ff9e6ff
|
|
| BLAKE2b-256 |
21c66cc45a780dead5637024efefade1ba6b2911a87007b80609ab191fc9dbd2
|
Provenance
The following attestation bundles were made for shopify_gql_helper-0.1.0.tar.gz:
Publisher:
upload-python-package.yml on tulayha/shopify-gql-helper-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shopify_gql_helper-0.1.0.tar.gz -
Subject digest:
cce7d8cf31d6fd8b4b3b5428b879bb34a940c54f75ad5fe2f0fa527736559b40 - Sigstore transparency entry: 430493706
- Sigstore integration time:
-
Permalink:
tulayha/shopify-gql-helper-py@522b9243d154e6061e0c4e4ebdf912f5d3bd19b5 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/tulayha
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
upload-python-package.yml@522b9243d154e6061e0c4e4ebdf912f5d3bd19b5 -
Trigger Event:
release
-
Statement type:
File details
Details for the file shopify_gql_helper-0.1.0-py3-none-any.whl.
File metadata
- Download URL: shopify_gql_helper-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38c4c9600504da4d655f7f4dfbcdcb9e58ea2a272a13ac082a6c8ce4e12847d9
|
|
| MD5 |
512195e028c910eb3a22b445c63cb03e
|
|
| BLAKE2b-256 |
20bfc2b3edc942b1e3b9e52e7608c6292675cc67ab6395356f6d49d27c3172fb
|
Provenance
The following attestation bundles were made for shopify_gql_helper-0.1.0-py3-none-any.whl:
Publisher:
upload-python-package.yml on tulayha/shopify-gql-helper-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shopify_gql_helper-0.1.0-py3-none-any.whl -
Subject digest:
38c4c9600504da4d655f7f4dfbcdcb9e58ea2a272a13ac082a6c8ce4e12847d9 - Sigstore transparency entry: 430493721
- Sigstore integration time:
-
Permalink:
tulayha/shopify-gql-helper-py@522b9243d154e6061e0c4e4ebdf912f5d3bd19b5 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/tulayha
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
upload-python-package.yml@522b9243d154e6061e0c4e4ebdf912f5d3bd19b5 -
Trigger Event:
release
-
Statement type: