0
votes

So i am trying to get all products from woocommerce rest api but it keeps on returning empty result like []. When I give the same API a product ID, it returns proper result but when I remove the product ID, it returns me nothing.

This is what works

https://example.com/wp-json/wc/v3/products/{PRODUCT-ID}?lang=en&consumer_key=ck_xxxxxxxxx&consumer_secret=cs_xxxxx

But when I try to get all products like this

https://example.com/wp-json/wc/v3/products?lang=en&consumer_key=ck_xxxxxxxxx&consumer_secret=cs_xxxxx

I keep on getting []

How can I get all the products from the rest API?

2

2 Answers

0
votes

Try the following:

https://example.com/wp-json/wc/v3/products?page=1&orderby=id&order=asc

That should give you the first 10 products as it usually goes 10 products per page (there are ways to request more, up to 100). Then you can go for the next page and the next page until they all download.