GraphQL Storefront API: Carts and Checkout
GraphQL Storefront API: Carts and Checkout
GraphQL Storefront API: Carts and Checkout
BigCommerce’s GraphQL Storefront API provides the same access to cart and checkout objects as the REST Storefront API. Having access to cart and checkout data in the graph alongside related data makes it easier to build headless storefront applications.
Developers can use frontend GraphQL to create an end-to-end shopper experience. Cart and checkout-related mutations and queries can do the following:
Limitations As of this writing, the GraphQL Storefront API does not support the following features:
To make requests, create a store-level API account with one or more of the following token creation OAuth scopes:
No additional scopes are required to use the GraphQL Storefront API.
To generate a bearer token to authenticate calls to the GraphQL Storefront API, use either the Create a storefront token or the Create a customer impersonation token REST endpoint. On a Stencil storefront, you can also access a token at render time using a Handlebars property. Learn more about Authenticating requests to the GraphQL Storefront API.
For more information, see Creating a token in Authenticating requests to the GraphQL Storefront API and dynamic tokens in the Authentication and example requests article.
To handle payments, use the Payments API (Overview).
For PCI compliance-related reasons, the GraphQL Storefront API does not handle payments. You can use the Payments API (Reference) to process payments.
The GraphQL Storefront API returns the checkout ID and order ID, which you can use to Get accepted payment methods and Create a payment access token.
The GraphQL Storefront API returns the customer ID, which you can use to Get stored payment instruments. To learn more about authenticating REST endpoints, locate the Authentication section at the top of each endpoint, then click Show Details.
Gift certificates are a type of payment instrument similar to a debit card, so the Payments API must apply the gift certificate to the checkout.
The API account you use to process payments must have the scopes specified in the Payments API Overview.
If using the getCart query with customer impersonation tokens, you must include the cart’s entityId.
You can use a cart redirect URL for embedded checkouts or to redirect your
checkout. You need a cartEntity ID. To create a cartEntity ID, use the
create a cart mutation.
The current platform limit is 250 metafields for a single cart. When you create metafields using the createCartMetafield mutation, the default namespace is bc_storefront.
We invite you to give feedback on the GraphQL Storefront schema and the capabilities of the API to let us know if it meets your needs. In particular, we want to know about anything that seems confusing, or anything that you think is missing. We want to ensure that this API meets your needs, and we’re open to adding features.
Join our Developer Community to share your feedback with us in the BigCommerceDevs Slack or on our Discord server.