GraphQL Storefront API
Inventory
Inventory settings

Get Inventory

You can query inventory information using the GraphQL Storefront API. The information accessible by any storefront API is controlled by the inventory settings for the store.

For example queries, see Query Inventory with the GraphQL Storefront API.

To work with inventory settings, the API account that generates Storefront tokens must include one of the following OAuth scopes:

UI NamePermissionParameter
Productsmodifystore_v2_products
Productsread-onlystore_v2_products_read_only

Use these scopes to read and change the following information:

  • The total inventory quantity of a particular product or variant that is available for shoppers across all visible locations
  • The inventory quantity of a particular variant that is available at a specified location

Settings to retrieve inventories

Inventory Settings

Regardless of physical stock levels, inventory quantities may return null depending on the store's inventory settings, accessible through the Settings API or the Settings > Inventory page in the store control panel.

In the following cases, inventory-related storefront queries may return different responses than expected:

CaseResponse
Out-of-stock products are hidden from the storefrontNo responses will contain that product
Stock levels are hidden from the storefrontInventory levels will always return null
Only products low in stock display inventory levelsInventory levels for products with quantities above the low-stock threshold will always return null

A store's inventory settings also affect inventory levels for variants. To see examples of these responses, see Query Inventory with the GraphQL Storefront API.

Location settings

  • When a location is enabled, its inventory of products and variants is accessible to the storefront. This inventory is included in the aggregate stock for a product or variant.
  • If a location is enabled and visible, its inventory is fetched when you query the stock for a variant at each location.

To enable locations and change location visibility, use the Update locations endpoint.

Resources

Did you find what you were looking for?