Magento – magento 2 web rest api – Get all products with a specific attribute code

apimagento2rest

I have some products with a custom attribute called "day_special" which may have a value of 'yes' or 'no'. When I called a product (say sku: abc115) through webapi (url: domain.com/rest/V1/products/abc115), It shows all the product details and the "day_special" attribute is there within the "custom_attributes" section and values in it.

Now I want to get all the products with a specific custom attribute. That is get all products with attributes "day_special" as "yes". Is there any rest api method which gives the mentioned results?

Best Answer

You can try using the catalogProductRepositoryV1 -> [GET] /V1/products

searchCriteria[filter_groups][0][filters][0][field]
searchCriteria[filter_groups][0][filters][0][value]
searchCriteria[filter_groups][0][filters][0][condition_type]

So the final URL will look like this:

http://<magento_host>/rest/V1/products?searchCriteria[filter_groups][0][filters][0][field]=custom_attribute_code&searchCriteria[filter_groups][0][filters][0][value]=custom_attribute_value&searchCriteria[filter_groups][0][filters][0][condition_type]=eq

References: http://devdocs.magento.com/swagger/

Related Topic