Storefront API - filtering on 'in stock only'

Hi guys,

Is there a way to filter products that are ‘in stock only’ in my storefront api call? Can you show me an example?

Found it :slight_smile:

{
shop {
products(first: 10, query: “published_status:published AND available_for_sale:true”)

}

}

1 Like

Hello dev88,
i) Using Admin Product API you can get all products array. used below Admin API to get Products

‘store_url/admin/products.json’

ii) get the “variants” from products array
iii) get “inventory_quantity” from “variants” array
iv) if “inventory_quantity” is grater than “0” then product is “In Stock” otherwise product is “Out of Stock”