I am asking this, but with some addition.
Getting Products by category id! Magento 2.1 REST
I am getting All Categories with ( I am using Magento 2 sample data )
http://www.myshop.com/rest/V1/categories
In that result for example i took Female Tops category which has id of 21 and ran request
http://www.myshop.com/rest/V1/categories/21/products
this returns me all products (50) with their SKU, But i need all data from products.
Now i tried couple of things to achieve this:
1. Get all products by their SKU which i get from their category
http://www.myshop.com/rest/V1/products?
searchCriteria[filter_groups][0][filters][0][field]=sku&searchCriteria[filter_groups][0][filters][0][value]=MH01&searchCriteria[filter_groups][0][filters][1][field]=sku&searchCriteria[filter_groups][0][filters][1][value]=MH02&searchCriteria[filter_groups][0][filters][2][field]=sku&searchCriteria[filter_groups][0][filters][2][value]=MH03
...
It works, But the problem with this is it might get HTTP Error 414 URL is too long (if there are too many products) and i think is not very efficient.
2. Get all products by their category ID
http://www.myshop.com/rest/V1/products?
searchCriteria[filter_groups][0][filters][0][field]=category_id&searchCriteria[filter_groups][0][filters][0][value]=21
This returns me 0 Products and I think I understand why, its because they are not in this category rather they are in child category (i saw that in custom_attributes key category_ids
(this is in fact where they "belong")), And also this will return me all products not just bundled as I want.
Is there a better way of getting products by their categories? Without writing new APIs. I just started using magento 2 APIs and maybe i overlooked something.