Get All products from Woocommerce REST API

I need to retrive the full product list from WooCommerce into WeWeb. But I simply can’t get paginsation (if the is the right word) to work? How do I setup WeWeb to retrieve the data in packets of 25 products, which is the current “items pr. page” the Woccomerce API gives me. I can increase it to 100, but it doesn’t solve my problem, as I have more than 2.000 products.

Any guidance will be highly appriciated. :wink:

Consider creating a dedicated products table in your database that mirrors your WooCommerce catalog. To keep this synchronized:

  1. Set up WooCommerce webhooks to detect product changes (creation, updates, deletions)
  2. Use these webhooks to automatically update your database table whenever products are modified in WooCommerce
  3. Implement pagination when querying your database table for better performance

We successfully implemented this same approach with Shopify, and it works well.

2 Likes

I don’t think it’s worth the hassle to go download and mantain your data synced in the way @bradley_gibson suggests unless you need to manipulate it somehow.

What you can do instead is rely on the Woo’s REST API - they have a comprehensive API documentation which allows for pagination as well (WooCommerce REST API Documentation - WP REST API v3) you just need to take the time to understand it and read it.

The REST API in my opinion is made for this, so it makes no sense - unless you have some specific needs that require downloading the whole thing and mantaining it synced, which in most cases you don’t. You can also filter pretty much anything if it fits the attributes of the given item. So I feel it’s really useless hassle to mirror it, unless you need. You can even fetch the various attributes the products have, the API is very comprehensive.

2 Likes

That can also work :grin:.

Our use case needed a central source of truth without limitations as we sync this data to multiple systems

1 Like

Hi,

I know the extensive woocommerce rest api very well and have done many projects in C#.

My issue is that the rest api only sends the data “pages” and I have to retrieve one page at a time. I do this very well in C#, by sending multiple requests.

But I can’t find a way to do it in weweb - other than a workflow. But if I look in the weweb documentation, a Fetch all pages feature is mentioned, but I can’t seem to find it in the software?

Is it for data processing or display?

1 Like

Display and selection. And based on that I will send api requests back to update the data - but updates only one product at the time.

The aim with the project is to facilitate a way to change WooCommerce product data for users without access to the WP admin panel.

Can you share the JSON you are getting when making a request using the pagination @Broberto mentioned?

Did you expose the full rest API to weweb? In WordPRess you get the total products and pages in the headers like “X-Total…” and “X-pages…”. I am doing the same, I connected a website to Weweb and just use the REST ApI to do the communication/sync between both. I use xano in the middle, but the loop/iterator in weweb should work fine also.