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 authenticated using basic HTTP authentication for your private app or using OAuth for your public or custom app. If you're authenticating to the Storefront API as a public app, then you need to turn your app into a sales channel.
The following example URL shows how you request unauthenticated scopes during OAuth:
You've obtained a Storefront API access token and included it in your request header:
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.