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 Name | Permission | Parameter |
---|---|---|
Products | modify | store_v2_products |
Products | read-only | store_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:
Case | Response |
---|---|
Out-of-stock products are hidden from the storefront | No responses will contain that product |
Stock levels are hidden from the storefront | Inventory levels will always return null |
Only products low in stock display inventory levels | Inventory 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
- GraphQL Storefront API Overview
- GraphQL Storefront API Reference
- GraphQL Storefront Playground
- GraphQL Storefront Explorer