shopify-setup
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseShopify Setup
Shopify 环境设置
Set up working Shopify CLI authentication and Admin API access for a store. Produces a verified API connection ready for product and content management.
为Shopify店铺配置可用的Shopify CLI身份验证与Admin API访问权限,创建可用于产品及内容管理的已验证API连接。
Workflow
操作流程
Step 1: Check Prerequisites
步骤1:检查前置条件
Verify the Shopify CLI is installed:
bash
shopify versionIf not installed:
bash
npm install -g @shopify/cli确认Shopify CLI已安装:
bash
shopify version若未安装:
bash
npm install -g @shopify/cliStep 2: Authenticate with the Store
步骤2:与店铺进行身份验证
bash
shopify auth login --store mystore.myshopify.comThis opens a browser for OAuth. The user must be a store owner or staff member with appropriate permissions.
After login, verify:
bash
shopify store infobash
shopify auth login --store mystore.myshopify.com此命令会打开浏览器进行OAuth验证,用户需为店铺所有者或拥有相应权限的工作人员。
登录完成后,验证连接:
bash
shopify store infoStep 3: Create a Custom App for API Access
步骤3:创建用于API访问的自定义应用
Custom apps provide stable Admin API access tokens (unlike CLI session tokens which expire).
Check if an app already exists: Ask the user if they have a custom app set up. If yes, skip to Step 4.
If no custom app exists, guide the user through creation via browser:
- Navigate to
https://{store}.myshopify.com/admin/settings/apps/development - Click Create an app
- Name it (e.g. "Claude Code Integration")
- Click Configure Admin API scopes
- Enable these scopes (see for details):
references/api-scopes.md- ,
read_productswrite_products - ,
read_contentwrite_content read_product_listings- ,
read_inventorywrite_inventory - ,
read_fileswrite_files
- Click Save then Install app
- Copy the Admin API access token (shown only once)
Use browser automation (Chrome MCP or playwright-cli) if the user prefers assistance navigating the admin.
自定义应用可提供稳定的Admin API访问令牌(与会过期的CLI会话令牌不同)。
检查是否已存在应用:询问用户是否已配置自定义应用,若是则跳过至步骤4。
若未创建自定义应用,引导用户通过浏览器操作:
- 访问
https://{store}.myshopify.com/admin/settings/apps/development - 点击创建应用
- 为应用命名(例如"Claude Code Integration")
- 点击配置Admin API权限范围
- 启用以下权限范围(详情请查看):
references/api-scopes.md- ,
read_productswrite_products - ,
read_contentwrite_content read_product_listings- ,
read_inventorywrite_inventory - ,
read_fileswrite_files
- 点击保存,然后点击安装应用
- 复制Admin API访问令牌(仅显示一次)
若用户需要协助操作后台,可使用浏览器自动化工具(Chrome MCP或playwright-cli)。
Step 4: Store the Access Token
步骤4:存储访问令牌
Store the token securely. Never commit it to git.
For project use — create :
.dev.varsSHOPIFY_STORE=mystore.myshopify.com
SHOPIFY_ACCESS_TOKEN=shpat_xxxxxxxxxxxxxxxxxxxxxEnsure is in .
.dev.vars.gitignoreFor cross-project use — store in Vault:
Use mcp__vault__secret_set with:
name: "shopify-{store-name}-token"
value: the access token
tags: ["shopify", "api"]安全存储令牌,切勿将其提交至git仓库。
项目内使用 — 创建文件:
.dev.varsSHOPIFY_STORE=mystore.myshopify.com
SHOPIFY_ACCESS_TOKEN=shpat_xxxxxxxxxxxxxxxxxxxxx确保已添加至文件中。
.dev.vars.gitignore跨项目使用 — 存储至Vault:
Use mcp__vault__secret_set with:
name: "shopify-{store-name}-token"
value: the access token
tags: ["shopify", "api"]Step 5: Verify API Access
步骤5:验证API访问权限
Test the connection with a simple GraphQL query:
bash
curl -s https://{store}.myshopify.com/admin/api/2025-01/graphql.json \
-H "Content-Type: application/json" \
-H "X-Shopify-Access-Token: {token}" \
-d '{"query": "{ shop { name primaryDomain { url } } }"}' | jq .Expected response includes the shop name and domain. If you get a 401, the token is invalid or expired — recreate the app.
使用简单的GraphQL查询测试连接:
bash
curl -s https://{store}.myshopify.com/admin/api/2025-01/graphql.json \
-H "Content-Type: application/json" \
-H "X-Shopify-Access-Token: {token}" \
-d '{"query": "{ shop { name primaryDomain { url } } }"}' | jq .预期响应应包含店铺名称及域名。若返回401错误,说明令牌无效或已过期,请重新创建应用。
Step 6: Save Store Config
步骤6:保存店铺配置
Create a in the project root for other skills to reference:
shopify.config.jsonjson
{
"store": "mystore.myshopify.com",
"apiVersion": "2025-01",
"tokenSource": ".dev.vars"
}在项目根目录创建文件,供其他技能调用:
shopify.config.jsonjson
{
"store": "mystore.myshopify.com",
"apiVersion": "2025-01",
"tokenSource": ".dev.vars"
}Critical Patterns
关键注意事项
API Version
API版本
Always specify an explicit API version (e.g. ). Using in production will break without warning. Shopify retires API versions quarterly.
2025-01unstable请始终指定明确的API版本(例如)。在生产环境中使用版本会无预警地出现故障,Shopify每季度会淘汰旧版API。
2025-01unstableToken Types
令牌类型
| Token | Format | Use |
|---|---|---|
| Admin API access token | | Custom apps — stable, long-lived |
| CLI session token | Short-lived | Shopify CLI commands only |
| Storefront API token | | Public storefront queries |
This skill sets up Admin API access tokens — the right choice for product and content management.
| 令牌类型 | 格式 | 用途 |
|---|---|---|
| Admin API访问令牌 | | 自定义应用使用 — 稳定、长期有效 |
| CLI会话令牌 | 短期有效 | 仅用于Shopify CLI命令 |
| Storefront API令牌 | | 公开店铺前台查询使用 |
本技能配置的是Admin API访问令牌,这是产品及内容管理的最佳选择。
Rate Limits
速率限制
Shopify uses a leaky bucket rate limiter:
- REST: 40 requests/second burst, 2/second sustained
- GraphQL: 1,000 cost points per second, max 2,000 points per query
For bulk operations, use the mutation instead of looping.
bulkOperationRunQueryShopify采用漏桶算法进行速率限制:
- REST接口:突发请求上限40次/秒,持续请求上限2次/秒
- GraphQL接口:每秒1000成本点,单查询最高2000成本点
对于批量操作,请使用突变而非循环调用。
bulkOperationRunQueryReference Files
参考文件
- — Admin API scopes needed for product and content management
references/api-scopes.md
- — 产品及内容管理所需的Admin API权限范围
references/api-scopes.md