GraphQL Storefront API Example Queries
Below are example GraphQL queries for use with the BigCommerce GraphQL Storefront API. The purpose of these examples is to assist developers in getting familiar with the API. For a general overview of its usage and capabilities, see GraphQL Storefront API overview.
Configuring the request
To get started, you need a BigCommerce store and a Storefront API token. For more information, see the Authenticating requests to the GraphQL Storefront API or the General authentication article.
For more information on formatting the request payload, see the query example section of the GraphQL Storefront API overview.
To use this API from a coupled storefront, use the following HTTP configuration:
To use this API server-to-server, use the following HTTP configuration:
Get a customer’s details
Get first three levels of category tree
Get category and products within by URL
Look up an object by URL
Get popular brands
Get a favicon
Get analytics ID
Analytics IDs are available only after configuring the analytics service provider for your store.
Get a list of countries
The geography node provides a list of all supported shipping countries and their corresponding states or provinces. By default, the full list is returned unless you apply a filter. To narrow down the list, you can use the Settings > Shipping > Checkout shipping options filter in the control panel. This filter limits the results to only those countries included in your active shipping zones.
The geography node currently supports two filters, both available on the level of countries: code and name. These require exact matches to the country’s two-letter country code and full name, respectively.
Geography Node
Geography Response
Shipping Settings
Shipping Response
Get wishlist information
Wishlists are accessible through GraphQL and offer access to all standard wishlist management functions. In addition to retrieving information through the queries customers.wishlists and site.publicWishlist outlined below, the mutations createWishlist, addWishlistItems, deleteWishlistItems, updateWishlist, and deleteWishlists are provided for managing customer wishlists.
Public wishlists are read-only within GraphQL.
The items field in both customer and public wishlist queries greatly increases query complexity. This means that the cost for deeply nested or large queries involving wishlist items grows rapidly. As a result, complex queries may hit rate or complexity limits sooner than expected. For platform stability, plan queries with this in mind and retrieve only the data you need.
Customer wishlists
Customer wishlists are queried based on the current customer session, using the token generated during the authentication process to identify the customer for the query’s response data.
Query
Response
Public wishlists
You can also access public wishlists using a token. The items field in public wishlists is affected by the same complexity considerations: