shopify
Shopify Admin & Storefront GraphQL APIs via curl. Products, orders, customers, inventory, metafields.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 4
- Forks
- 1
01 前言 Front Matter
- name
- shopify
- version
- 1.0.0
- description
- Shopify Admin & Storefront GraphQL APIs via curl. Products, orders, customers, inventory, metafields.
03 SKILL.md 正文
When to Use
Use when reading or querying Shopify store data (products, orders, customers, inventory, metafields) via the Admin or Storefront GraphQL APIs using curl — no SDK needed. For order mutations or app development, prefer the official libraries.
Workflow
- Get credentials. Admin: a private/custom app admin API access token sent as
X-Shopify-Access-Token. Storefront: a storefront access token sent asX-Shopify-Storefront-Access-Token(safe to expose client-side). - Pick the endpoint. Admin:
https://{store}.myshopify.com/admin/api/2026-01/graphql.json. Storefront:https://{store}.myshopify.com/api/2026-01/graphql.json. - Query. Use
curl -s -X POSTwith a JSON body containingqueryand optionalvariables.
Admin — products with variants
curl -s -X POST "https://{store}.myshopify.com/admin/api/2026-01/graphql.json" \
-H "Content-Type: application/json" \
-H "X-Shopify-Access-Token: $SHOPIFY_ADMIN_TOKEN" \
-d '{
"query": "query { products(first: 10) { edges { node { id title handle status variants(first: 5) { edges { node { id title sku price } } } } } } }"
}'
Admin — recent orders
curl -s -X POST "https://{store}.myshopify.com/admin/api/2026-01/graphql.json" \
-H "Content-Type: application/json" \
-H "X-Shopify-Access-Token: $SHOPIFY_ADMIN_TOKEN" \
-d '{
"query": "query { orders(first: 10, sortKey: CREATED_AT, reverse: true) { edges { node { id name createdAt totalPriceSet { shopMoney { amount currencyCode } } } } } }"
}'
Admin — customers
curl -s -X POST "https://{store}.myshopify.com/admin/api/2026-01/graphql.json" \
-H "Content-Type: application/json" \
-H "X-Shopify-Access-Token: $SHOPIFY_ADMIN_TOKEN" \
-d '{"query": "query { customers(first: 10) { edges { node { id email firstName lastName ordersCount } } } }"}'
Admin — inventory locations then levels
curl -s -X POST "https://{store}.myshopify.com/admin/api/2026-01/graphql.json" \
-H "Content-Type: application/json" \
-H "X-Shopify-Access-Token: $SHOPIFY_ADMIN_TOKEN" \
-d '{"query": "query { locations(first: 10) { edges { node { id name } } } }"}'
Then query inventoryLevels(locationId: "LOCATION_ID") { nodes { available } } for stock per variant.
Admin — metafields on a product
curl -s -X POST "https://{store}.myshopify.com/admin/api/2026-01/graphql.json" \
-H "Content-Type: application/json" \
-H "X-Shopify-Access-Token: $SHOPIFY_ADMIN_TOKEN" \
-d '{
"query": "query { product(id: \"gid://shopify/Product/PRODUCT_ID\") { metafields(first: 10) { edges { node { namespace key value type } } } } }"
}'
Storefront — products (public, client-safe)
curl -s -X POST "https://{store}.myshopify.com/api/2026-01/graphql.json" \
-H "Content-Type: application/json" \
-H "X-Shopify-Storefront-Access-Token: $SHOPIFY_STOREFRONT_TOKEN" \
-d '{"query": "query { products(first: 10) { edges { node { id title handle availableForSale } } } }"}'
Pagination (cursor)
Shopify returns pageInfo { hasNextPage endCursor }; pass the cursor to the next request:
curl -s -X POST "https://{store}.myshopify.com/admin/api/2026-01/graphql.json" \
-H "Content-Type: application/json" \
-H "X-Shopify-Access-Token: $SHOPIFY_ADMIN_TOKEN" \
-d '{
"query": "query { products(first: 10, after: \"CURSOR\") { edges { node { id title } } pageInfo { hasNextPage endCursor } } }"
}'
Pitfalls
- Admin API rate limit: 2 requests/second (burst 40). Storefront: 4 requests/second (burst 60). Monitor the
X-Shopify-Shop-Api-Call-Limitresponse header; back off with jitter on 429s. - IDs are opaque GIDs (
gid://shopify/Product/123) — always pass them as strings and URL-encode them inside query variables. - Product
statusis DRAFT/ACTIVE/ARCHIVED; use thequery:argument to filter list queries. - The Storefront API only exposes published, sales-channel-visible data — don't use it for admin reads.
- Never hardcode tokens in scripts — use env vars (e.g.
$SHOPIFY_ADMIN_TOKEN); keep them out of logs and reports. - The
2026-01version segment is pinned — Shopify deprecates API versions, so update it on a schedule.
Verification
- Confirm the response has no
errorskey; if present, fix the query before trusting data. - Sanity-check counts: products returned vs. expected catalog size; order timestamps within the expected window.
- For storefront calls, verify the query works with the public token only (no admin auth).
- During bulk loops, watch the rate-limit header stays under limits.
04 同仓库更多 Skills
macbook-linux-maintenance
Legacy MacBook Linux fixes: GPU wedge, reboot hang, thermal.
governance-regression-triage
Triage a host's governance issues: what changed.
enforcement-immutability
Use when enforcement files lose their immutable flag.
steadfaste-fleet-repo-deploy
Use when committing to the steadfaste-fleet repo.
steadfaste-fleet-maintenance
Maintain an installed Steadfaste Fleet instance — update both the upstream Hermes Agent and the fleet repo layer, merge diverged histories, sync skills safely, and troubleshoot common issues. Covers the dual-update workflow (hermes update + fleet-update.sh), encrypted brain data backup, mycortex import, and recovery techniques.
fleet-preflight
DEPRECATED alias — merged into survey-before-action (2026-08-20). Load survey-before-action instead; its "Repo-Specific Pre-Flight" section covers git search, Hermes boundary, and deployment verification.