Magento – Magento 2 REST API get all enabled categories

magento2rest api

Wanted to use REST API to get all categories where is_active attribute is true.

Here is endpoint I am calling https://www.domain.com/rest/default/V1/categories

Which giving me all the categories is_active is true and false.

I tried to add filters but didnt work either.

https://www.domain.com/rest/default/V1/categories?searchCriteria[filterGroups][0][filters][0][field]=is_active&searchCriteria[filterGroups][0][filters][0][value]=true&searchCriteria[filterGroups][0][filters][0][conditionType]=eq

Could someone help how to apply filter on category to get only active categories?

Best Answer

Use the below code in Postman you will find all the categories

Endpoint: “http(s)://yourdomain.com/rest/ V1/categories/list”

Method: GET
Request: searchCriteria.
Header: Authorization : Bearer (Token)
Response: token(string)

Reference : This is a reference link for the code

Also, try replacing the " list " with the default category Id. Say Default Category Id is 2. Then the endpoint will be below

Endpoint: “http(s)://yourdomain.com/rest/V1/categories/2”

Try below:

Endpoint - http://yourdomain.com/index.php/rest/all/V1/categories

Note: Make sure you pass all keyword in Url and it will works

Related Topic