Fetch products by category in Woocommerce REST API
In this case you should use the filters...
however, It worked for me :
http://www.example.com/wp-json/wc/v1/products?category=16
the 16 is a sample of category id...
According to the WooThemes/WooCommerce documentation you need to use filters
, like you say, only you appear to have the filter name wrong.
Try:
https://mysite.com/wc-api/v1/products?filter[categories]=gedgets&consumer_key=ck_9354534x&consumer_secret=cs_dx7345345
categories
is the name of the field returned by the API, so that should be what you use.
Just in case anyone is trying to achieve this in the future with v2 of the Woo REST API, this is how it's done:
https://${baseUrl}/wp-json/wc/v2/products?category=${categoryId}
And if you only have the slug of the category, as opposed to the id, you can first:
https://${baseUrl}/wp-json/wc/v2/products/categories?slug=${categorySlug}