← [ BACK_TO_NOTES ]

Shopify Storefront API

Shopify Storefront API 是 GraphQL 接口,用于构建自定义店铺前端和无头电商体验

#concept #growing #dev #shopify #graphql

[!info] related notes

Shopify Storefront API

一句话定义

Shopify Storefront API 是面向客户的 GraphQL 接口,用于构建自定义店铺前端、移动应用、无头商务体验,提供产品、集合、购物车等前端所需数据。

核心机制

无头商务架构

自定义前端(React/Vue/Next.js)
    ↓
Storefront API (GraphQL)
    ↓
Shopify 后端
    ↓
结账(Shopify Checkout)

权限特点

  • 只读为主:查询产品、集合、文章
  • 有限写入:添加购物车、创建客户、结账
  • 公开访问:无需 OAuth,使用 Storefront Access Token

最小例子

获取产品

query {
  products(first: 10) {
    edges {
      node {
        title
        description
        priceRange {
          minVariantPrice {
            amount
          }
        }
        images(first: 1) {
          edges {
            node {
              url
            }
          }
        }
      }
    }
  }
}

添加到购物车

mutation {
  cartLinesAdd(cartId: "gid://shopify/Cart/123", lines: [
    {merchandiseId: "gid://shopify/ProductVariant/456", quantity: 1}
  ]) {
    cart {
      id
      lines(first: 10) {
        edges {
          node {
            merchandise {
              ... on ProductVariant {
                title
                priceV2 {
                  amount
                }
              }
            }
          }
        }
      }
    }
  }
}

适用场景

  1. React/Next.js 自定义前端
  2. 移动应用(iOS/Android)
  3. 语音商务(Alexa)
  4. IoT 设备购物
创建于 2026/6/15 更新于 2026/7/15
Digital Biome
Access

键盘导航

j / k / ↑ / ↓
选择对象
Enter / o
打开选择
/ 或 Ctrl+K
全站搜索
i / f / 1–4
筛选当前列表
g → h / l / p / t / a
首页 / 笔记 / 项目 / 工具 / About
r → 1–9
打开所选对象的关联
u
返回上一页
Esc
关闭浮层 / 取消命令;输入框内清空文本