WooCommerce Rest API get products by slug

New to WooCommerce, and using the REST API to get products which I have successfully done.

Not sure on how to get a single product using the slug as permalink gives full url, where as i only need the end slug so I can have clean urls and not use the id to find a record. I know with the WordPress rest api plugin you can do this posts-api?filter[name]== and get the post by product slug, rather than use:

Read More
/wc-api/v3/products/id

I want to be able to do:

/wc-api/v3/products/slug

Related posts

1 comment

  1. You just have to adjust the query slightly /wc-api/v3/products/slug should be /wc-api/v3/products/?slug=your-product-slug.

    One important difference is that this will return the slug inside an array, so you will have to select the first object in the array once you have parsed it.

Comments are closed.