Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jobthomas/32e80576d6d729a64122396739272a42 to your computer and use it in GitHub Desktop.
Save jobthomas/32e80576d6d729a64122396739272a42 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]}'
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment