Skip to main content

Storefront API

The Storefront API lets you query the GraphQL Storefront API to read product, collection, and other storefront data from within your extension. Use this API to display product recommendations, look up collection details, or fetch any publicly available storefront information.

This API requires the api_access capability. Enable it under [extensions.capabilities] in your extension's configuration.

For customer and order data, use the Customer Account API.

  • Display product recommendations: Query products by collection or tag and render personalized suggestions on customer account pages.
  • Show order-related products: Fetch product details for items in a customer's order to display warranty information, care instructions, or upsell opportunities.
  • Build collection browsers: Query collections to let customers browse and save products directly from a full-page extension.
  • Enrich extension content with storefront data: Pull product images, descriptions, and pricing to create rich, data-driven extension experiences.
Support
Targets (24)

The shopify global object provides the query interface for the GraphQL Storefront API. Access the following properties on shopify to fetch product, collection, and other storefront data.

Anchor to query
query
<Data = unknown, Variables = { [key: string]: unknown; }>(query: string, options?: { variables?: Variables; version?: ; }) => Promise<{ data?: Data; errors?: []; }>
required

Queries the Storefront GraphQL API directly from your extension using a prefetched token. Use this to fetch product data, collection details, or other storefront information without routing requests through your app backend.

Requires the api_access capability.


  • Prefer shopify.query() over raw fetch(): The query helper automatically handles GraphQL Storefront API authentication, versioning, and request formatting. Use fetch() only when you need lower-level control over the request.
  • Request only the fields you need: Write targeted GraphQL queries that select specific fields rather than requesting entire objects. This reduces response size and improves extension performance.
  • Cache responses when appropriate: If you're querying data that doesn't change frequently (such as collection metadata), store the result in component state to avoid redundant network requests on re-renders.
  • Handle errors and loading states: Always check for errors in the GraphQL response and display appropriate loading indicators while queries are in flight.

  • Query complexity and rate limits from the GraphQL Storefront API still apply. Extensions that issue many concurrent queries may be throttled.

Was this page helpful?