Skip to content

Instantly share code, notes, and snippets.

@gedex
Last active June 9, 2018 13:13
Show Gist options
  • Select an option

  • Save gedex/2ac3df9c3ed05081dc0fe71eff99c605 to your computer and use it in GitHub Desktop.

Select an option

Save gedex/2ac3df9c3ed05081dc0fe71eff99c605 to your computer and use it in GitHub Desktop.
Brands REST API in 1.5.0

Brands REST API

The Brands REST API allows you to create, view, update, and delete individual, or a batch, of brands. The endpoint is /wp-json/wc/v1/products/brands which basically mimics /wp-json/wc/v1/products/categories. You can refer to the same documentation of product categories REST API.

In addition to /products/brands endpoints, the /products endpoints also updated to display brands in the response and check the JSON request for brands.

Examples

  • Retrieve all product brands:

    curl https://example.com/wp-json/wc/v1/products/brands -u consumer_key:consumer_secret
    
  • Create a product brand:

    curl -X POST https://example.com/wp-json/wc/v1/products/brands \
     -u consumer_key:consumer_secret \
     -H "Content-Type: application/json" \
     -d '{
     "name": "Apple",
     "image": {
       "src": "https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Apple_logo_black.svg/768px-Apple_logo_black.svg.png"
      }
    }'
    
  • Delete a product brand:

    curl -X DELETE https://example.com/wp-json/wc/v1/products/brands/9?force=true -u consumer_key:consumer_secret
    
  • Set brands to a product:

     -u consumer_key:consumer_secret \
     -H 'Content-Type: application/json' \
     -d '{"id": "4304", "brands": [48, 49]}'
    
@Qle63

Qle63 commented Dec 9, 2016

Copy link
Copy Markdown

Is this a happening thing?
Would love to have Brands via Rest API.

@eladvider-softangible

Copy link
Copy Markdown

im trying to use REST API for brnads with the following route : products/Brands
and i get 404 "No route was found matching the URL and request method"

using WooCommerce - 2.6.14
Brands for WooCommerce – 1.0.2

thanks

@corsonr

corsonr commented Jun 23, 2017

Copy link
Copy Markdown

Hey @gedex you need to remove extra spaces before each snippets to make the display correct ;-)

@Luminus

Luminus commented May 10, 2018

Copy link
Copy Markdown

Hey @gedex the link to the product categories REST API in the first paragraph is broken. It points to https://woothemes.github.io/instead of https://woocommerce.github.io/

@samarthagarwal

Copy link
Copy Markdown

Does it allow retrieving products from a particular brand?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment