Shopify Storefront API

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

#type / concept #status / growing #tech / dev #resource / shopify #protocol / 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/6/15