Getting started with the Storefront API
The Storefront API provides unauthenticated access using GraphQL to products, collections, customers, checkouts, and other store resources that you can use to build custom purchasing experiences.
This tutorial shows you how to accomplish some common tasks with the Storefront API.
You've created a private app or custom app with Storefront API access enabled in the app setup. If you've created a public app, then you need to turn your app into a sales channel.
For private apps, you've chosen which permissions to enable on the Storefront API section of the private app page. Your Storefront API access token will be available to copy/paste after you've saved the private app with Storefront API enabled.
The following example URL shows a request for unauthenticated scopes:
After your public or custom app is installed, your app can request a Storefront API access token from the Admin API using the
StorefrontAccessTokenREST resource or the
After your app has a Storefront API access token, include it in the request header on each request to the Storefront API:
Storefront GraphQL endpoint
All Storefront API queries are made on a single GraphQL endpoint, which only accepts POST requests:
To retrieve a list of products, you can query
products field uses an argument (for example,
first) to specify the number of results to retrieve.
The following example shows how to retrieve the IDs of the first 5 products in your store. For more information on selecting which set of results to retrieve, refer to Paginating results with GraphQL.
Retrieve a single product
Products are identified by a globally unique ID, which can be used to query for information. To retrieve a single product, you can use the
product field at the query root and provide the product ID.
Retrieve product variants
A product variant represents a different version of a product, such as differing sizes or differing colors. You can retrieve the variants associated with a product by querying
variants on the
Retrieve product media
You can use the Storefront API to retrieve a product's media and display it on a storefront.
media field on the
Product type to query for a product's media. Then use a fragment to specify the fields that you want to return for each possible media type.
A collection represents a grouping of products that a store owner can create to organize them or make their stores easier to browse. For example, a merchant might create a collection for a specific type of product that they sell, such as footwear.
Merchants can create collections by selecting products individually or by defining rules that automatically determine whether products are included.
The following example shows how to query for collections and the products that belong to those collections.
- Explore the storefront-api-learning-kit project on GitHub to access a complete set of sample queries that you can use in the Insomnia HTTP client.
- Visit the storefront-api-examples project on GitHub to access example apps built with a variety of open-source libraries.
- Learn about the different tools you can use to create unique buying experiences anywhere your customers are, including websites, apps, and video games.
- Share feedback on the Storefront API.