window.stockful. It provides methods to fetch live inventory data, with built-in caching.
The JS bundle is under 2 KB and loads with defer - it won’t block page rendering.
Setup
The API is automatically available when the Stockful app embed is enabled in the theme editor (App embeds > Stockful). No additional setup is required.Waiting for the API
The API dispatches astockful:ready event on window once initialized:
Methods
getVariant
Fetch inventory data for a single product variant.variantId- Shopify numeric variant ID
VariantData object or null if not found.
getProduct
Fetch aggregated inventory data for a product (across all variants).productId- Shopify numeric product ID
ProductData object or null if not found.
getVariants
Fetch inventory data for multiple variants in a single request.variantIds- Array of Shopify numeric variant IDs (max 50)
VariantData objects. Variants not found are omitted.
getLocationAvailability
Fetch per-location stock for a variant. This returns live data from Shopify.variantId- Shopify numeric variant ID
LocationData objects, filtered by the store’s visibility settings.
Types
VariantData
ProductData
LocationData
Events
stockful:ready
Dispatched onwindow when the API has initialized.
Caching
All methods cache responses in memory for 30 seconds. The server also returnsCache-Control headers (30s for variant/product data, 60s for location data), so the browser may serve cached responses beyond the JS cache.
There is no manual cache invalidation - after 30 seconds, the next call for the same data will make a fresh request.