0

How to get subcategries for each category in REST API?

I tried to get category as:

https://domain.com/index.php/rest/V1/categories/:categoryID

2 Answers 2

1

That is correct, are you sure you're using a valid category ID? Example:

https://domain.com/rest/V1/categories/2

Then you can get the sub categories from the response, response.children.

2
  • 2
    Just for future reference, with that endpoint, response.children returns a comma separated list of child IDs. Jan 30, 2018 at 13:28
  • @PaulBlundell The painful turth that Magento like to develop the Framework to 75% of it's maximum potenial. Leave the 25% to the Community
    – MackieeE
    Aug 13, 2019 at 9:36
1

Your method is correct, but it will only return all child category ID's in comma-separated numbers. If you want to get sub-category information, then you need to write down a custom module with webapi.xml for your custom route to write a logic for this. This is not possible without doing customization in interface method.

Thanks

Rahul Anand

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.