Skip to main content

Products

The products API allows you to create, view, update, and delete individual, or a batch, of products.

Product properties

AttributeTypeDescription
idintegerUnique identifier for the resource. READ-ONLY
namestringProduct name.
slugstringProduct slug.
permalinkstringProduct URL. READ-ONLY
date_createddate-timeThe date the product was created, in the site's timezone. READ-ONLY
date_modifieddate-timeThe date the product was last modified, in the site's timezone. READ-ONLY
typestringProduct type. Default is simple. Options (plugins may add new options): simple, grouped, external, variable.
statusstringProduct status (post status). Default is publish. Options (plugins may add new options): draft, pending, private and publish.
featuredbooleanFeatured product. Default is false.
catalog_visibilitystringCatalog visibility. Default is visible. Options: visible (Catalog and search), catalog (Only in catalog), search (Only in search) and hidden (Hidden from all).
descriptionstringProduct description.
short_descriptionstringProduct short description.
skustringUnique identifier.
pricestringCurrent product price. This is setted from regular_price and sale_price. READ-ONLY
regular_pricestringProduct regular price.
sale_pricestringProduct sale price.
date_on_sale_fromstringStart date of sale price. Date in the YYYY-MM-DD format.
date_on_sale_tostringSets the sale end date. Date in the YYYY-MM-DD format.
price_htmlstringPrice formatted in HTML, e.g. <del><span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">&#36;&nbsp;3.00</span></span></del> <ins><span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">&#36;&nbsp;2.00</span></span></ins> READ-ONLY
on_salebooleanShows if the product is on sale. READ-ONLY
purchasablebooleanShows if the product can be bought. READ-ONLY
total_salesintegerAmount of sales. READ-ONLY
virtualbooleanIf the product is virtual. Virtual products are intangible and aren't shipped. Default is false.
downloadablebooleanIf the product is downloadable. Downloadable products give access to a file upon purchase. Default is false.
downloadsarrayList of downloadable files. See Downloads properties.
download_limitintegerAmount of times the product can be downloaded, the -1 values means unlimited re-downloads. Default is -1.
download_expiryintegerNumber of days that the customer has up to be able to download the product, the -1 means that downloads never expires. Default is -1.
download_typestringDownload type, this controls the schema on the front-end. Default is standard. Options: 'standard' (Standard Product), application (Application/Software) and music (Music).
external_urlstringProduct external URL. Only for external products.
button_textstringProduct external button text. Only for external products.
tax_statusstringTax status. Default is taxable. Options: taxable, shipping (Shipping only) and none.
tax_classstringTax class.
manage_stockbooleanStock management at product level. Default is false.
stock_quantityintegerStock quantity. If is a variable product this value will be used to control stock for all variations, unless you define stock at variation level.
in_stockbooleanControls whether or not the product is listed as "in stock" or "out of stock" on the frontend. Default is true.
backordersstringIf managing stock, this controls if backorders are allowed. If enabled, stock quantity can go below 0. Default is no. Options are: no (Do not allow), notify (Allow, but notify customer), and yes (Allow).
backorders_allowedbooleanShows if backorders are allowed. READ-ONLY
backorderedbooleanShows if a product is on backorder (if the product have the stock_quantity negative). READ-ONLY
sold_individuallybooleanAllow one item to be bought in a single order. Default is false.
weightstringProduct weight in decimal format.
dimensionsobjectProduct dimensions. See Dimensions properties.
shipping_requiredbooleanShows if the product need to be shipped. READ-ONLY
shipping_taxablebooleanShows whether or not the product shipping is taxable. READ-ONLY
shipping_classstringShipping class slug. Shipping classes are used by certain shipping methods to group similar products.
shipping_class_idintegerShipping class ID. READ-ONLY
reviews_allowedbooleanAllow reviews. Default is true.
average_ratingstringReviews average rating. READ-ONLY
rating_countintegerAmount of reviews that the product have. READ-ONLY
related_idsarrayList of related products IDs (integer). READ-ONLY
upsell_idsarrayList of up-sell products IDs (integer). Up-sells are products which you recommend instead of the currently viewed product, for example, products that are more profitable or better quality or more expensive.
cross_sell_idsarrayList of cross-sell products IDs. Cross-sells are products which you promote in the cart, based on the current product.
parent_idintegerProduct parent ID (post_parent).
purchase_notestringOptional note to send the customer after purchase.
categoriesarrayList of categories. See Categories properties.
tagsarrayList of tags. See Tags properties.
imagesarrayList of images. See Images properties
attributesarrayList of attributes. See Attributes properties.
default_attributesarrayDefaults variation attributes, used only for variations and pre-selected attributes on the frontend. See Default Attributes properties.
variationsarrayList of variations. See Variations properties
grouped_productsarrayList of grouped products ID, only for group type products. READ-ONLY
menu_orderintegerMenu order, used to custom sort products.

Download properties

AttributeTypeDescription
idstringFile ID.
namestringFile name.
filestringFile URL. In write-mode you can use this property to send new files.

Dimension properties

AttributeTypeDescription
lengthstringProduct length in decimal format.
widthstringProduct width in decimal format.
heightstringProduct height in decimal format.

Category properties

AttributeTypeDescription
idintegerCategory ID.
namestringCategory name. READ-ONLY
slugstringCategory slug. READ-ONLY

Tag properties

AttributeTypeDescription
idintegerTag ID.
namestringTag name. READ-ONLY
slugstringTag slug. READ-ONLY

Image properties

AttributeTypeDescription
idintegerImage ID (attachment ID). In write-mode used to attach pre-existing images.
date_createddate-timeThe date the image was created, in the site's timezone. READ-ONLY
date_modifieddate-timeThe date the image was last modified, in the site's timezone. READ-ONLY
srcstringImage URL. In write-mode used to upload new images.
namestringImage name.
altstringImage alternative text.
positionintegerImage position. 0 means that the image is featured.

Attribute properties

AttributeTypeDescription
idintegerAttribute ID (required if is a global attribute).
namestringAttribute name (required if is a non-global attribute).
positionintegerAttribute position.
visiblebooleanDefine if the attribute is visible on the "Additional Information" tab in the product's page. Default is false.
variationbooleanDefine if the attribute can be used as variation. Default is false.
optionsarrayList of available term names of the attribute.

Default attribute properties

AttributeTypeDescription
idintegerAttribute ID (required if is a global attribute).
namestringAttribute name (required if is a non-global attribute).
optionstringSelected attribute term name.

Variation properties

AttributeTypeDescription
idintegerVariation ID. READ-ONLY
date_createddate-timeThe date the variation was created, in the site's timezone. READ-ONLY
date_modifieddate-timeThe date the variation was last modified, in the site's timezone. READ-ONLY
permalinkstringVariation URL. READ-ONLY
skustringUnique identifier.
pricestringCurrent variation price. This is setted from regular_price and sale_price. READ-ONLY
regular_pricestringVariation regular price.
sale_pricestringVariation sale price.
date_on_sale_fromstringStart date of sale price. Date in the YYYY-MM-DD format.
date_on_sale_tostringStart date of sale price. Date in the YYYY-MM-DD format.
on_salebooleanShows if the variation is on sale. READ-ONLY
purchasablebooleanShows if the variation can be bought. READ-ONLY
visiblebooleanIf the variation is visible.
virtualbooleanIf the variation is virtual. Virtual variations are intangible and aren't shipped. Default is false.
downloadablebooleanIf the variation is downloadable. Downloadable variations give access to a file upon purchase. Default is false.
downloadsarrayList of downloadable files. See Downloads properties.
download_limitintegerAmount of times the variation can be downloaded, the -1 values means unlimited re-downloads. Default is -1.
download_expiryintegerNumber of days that the customer has up to be able to download the variation, the -1 means that downloads never expires. Default is -1.
tax_statusstringTax status. Default is taxable. Options: taxable, shipping (Shipping only) and none.
tax_classstringTax class.
manage_stockboolean, stringStock management at variation level. Possible values are either a boolean or parent. Default is false.
stock_quantityintegerStock quantity. If is a variable variation this value will be used to control stock for all variations, unless you define stock at variation level.
in_stockbooleanControls whether or not the variation is listed as "in stock" or "out of stock" on the frontend. Default is true.
backordersstringIf managing stock, this controls if backorders are allowed. If enabled, stock quantity can go below 0. Default is no. Options are: no (Do not allow), notify (Allow, but notify customer), and yes (Allow).
backorders_allowedbooleanShows if backorders are allowed." READ-ONLY
backorderedbooleanShows if a variation is on backorder (if the variation have the stock_quantity negative). READ-ONLY
weightstringVariation weight in decimal format.
dimensionsobjectVariation dimensions. See Dimensions properties.
shipping_classstringShipping class slug. Shipping classes are used by certain shipping methods to group similar products.
shipping_class_idintegerShipping class ID. READ-ONLY
imagearrayVariation featured image. Only position 0 will be used. See Images properties.
attributesarrayList of variation attributes. See Variation Attributes properties

Variation attribute properties

AttributeTypeDescription
idintegerAttribute ID (required if is a global attribute).
namestringAttribute name (required if is a non-global attribute).
optionstringSelected attribute term name.

Create a product

This API helps you to create a new product.

POST /wp-json/wc/v1/products

Example of how to create a simple product:

curl -X POST https://example.com/wp-json/wc/v1/products \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "Premium Quality",
"type": "simple",
"regular_price": "21.99",
"description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
"short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
"categories": [
{
"id": 9
},
{
"id": 14
}
],
"images": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg",
"position": 0
},
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg",
"position": 1
}
]
}'

Example of how to create a variable product with global and non-global attributes:

curl -X POST https://example.com/wp-json/wc/v1/products \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "Ship Your Idea",
"type": "variable",
"description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
"short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
"categories": [
{
"id": 9
},
{
"id": 14
}
],
"images": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg",
"position": 0
},
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_back.jpg",
"position": 1
},
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg",
"position": 2
},
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_back.jpg",
"position": 3
}
],
"attributes": [
{
"id": 6,
"position": 0,
"visible": false,
"variation": true,
"options": [
"Black",
"Green"
]
},
{
"name": "Size",
"position": 0,
"visible": true,
"variation": true,
"options": [
"S",
"M"
]
}
],
"default_attributes": [
{
"id": 6,
"option": "Black"
},
{
"name": "Size",
"option": "S"
}
],
"variations": [
{
"regular_price": "19.99",
"image": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg",
"position": 0
}
],
"attributes": [
{
"id": 6,
"option": "black"
},
{
"name": "Size",
"option": "S"
}
]
},
{
"regular_price": "19.99",
"image": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg",
"position": 0
}
],
"attributes": [
{
"id": 6,
"option": "green"
},
{
"name": "Size",
"option": "M"
}
]
}
]
}'

Retrieve a product

This API lets you retrieve and view a specific product by ID.

GET /wp-json/wc/v1/products/<id>
curl https://example.com/wp-json/wc/v1/products/162 \
-u consumer_key:consumer_secret

List all products

This API helps you to view all the products.

GET /wp-json/wc/v1/products
curl https://example.com/wp-json/wc/v1/products \
-u consumer_key:consumer_secret

Available parameters

ParameterTypeDescription
contextstringScope under which the request is made; determines fields present in response. Options: view and edit.
pageintegerCurrent page of the collection.
per_pageintegerMaximum number of items to be returned in result set.
searchstringLimit results to those matching a string.
afterstringLimit response to resources published after a given ISO8601 compliant date.
beforestringLimit response to resources published before a given ISO8601 compliant date.
dates_are_gmtbooleanInterpret after and before as UTC dates when true.
excludestringEnsure result set excludes specific ids.
includestringLimit result set to specific ids.
offsetintegerOffset the result set by a specific number of items.
orderstringOrder sort attribute ascending or descending. Default is asc. Options: asc and desc.
orderbystringSort collection by object attribute. Default is date, Options: date, id, include, title and slug.
slugstringLimit result set to products with a specific slug.
statusstringLimit result set to products assigned a specific status. Default is any. Options: any, draft, pending, private and publish.
customerstringLimit result set to orders assigned a specific customer.
categorystringLimit result set to products assigned a specific category, e.g. ?category=9,14.
tagstringLimit result set to products assigned a specific tag, e.g. ?tag=9,14.
shipping_classstringLimit result set to products assigned a specific shipping class, e.g. ?shipping_class=9,14.
attributestringLimit result set to products with a specific attribute, e.g. ?attribute=pa_color.
attribute_termstringLimit result set to products with a specific attribute term (required an assigned attribute), e.g. ?attribute=pa_color&attribute_term=9,14.
skustringLimit result set to products with a specific SKU.

Update a product

This API lets you make changes to a product.

PUT /wp-json/wc/v1/products/<id>
curl -X PUT https://example.com/wp-json/wc/v1/products/162 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"regular_price": "24.54"
}'

Delete a product

This API helps you delete a product.

DELETE /wp-json/wc/v1/products/<id>
curl -X DELETE https://example.com/wp-json/wc/v1/products/162?force=true \
-u consumer_key:consumer_secret

Available parameters

ParameterTypeDescription
forcestringUse true whether to permanently delete the product, Default is false.

Batch update products

This API helps you to batch create, update and delete multiple products.

note

Note: By default it's limited to up to 100 objects to be created, updated or deleted.

POST /wp-json/wc/v1/products/batch
curl -X POST https://example.com/wp-json/wc/v1/products/batch \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"create": [
{
"name": "Woo Single #1",
"type": "simple",
"regular_price": "21.99",
"virtual": true,
"downloadable": true,
"downloads": [
{
"name": "Woo Single",
"file": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg"
}
],
"categories": [
{
"id": 11
},
{
"id": 13
}
],
"images": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg",
"position": 0
}
]
},
{
"name": "New Premium Quality",
"type": "simple",
"regular_price": "21.99",
"description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
"short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
"categories": [
{
"id": 9
},
{
"id": 14
}
],
"images": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg",
"position": 0
},
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg",
"position": 1
}
]
}
],
"update": [
{
"id": 165,
"variations": [
{
"id": 170,
"regular_price": "29.99"
},
{
"id": 172,
"regular_price": "29.99"
}
]
}
],
"delete": [
162
]
}'

Retrieve product reviews

This API lets you retrieve and view a specific product review by ID.

GET /wp-json/wc/v1/products/<product_id>/reviews/<id>
curl https://example.com/wp-json/wc/v1/products/162/reviews/9 \
-u consumer_key:consumer_secret

Product review properties

AttributeTypeDescription
idintegerUnique identifier for the resource. READ-ONLY
date_createdstringThe date the review was created, in the site's timezone. READ-ONLY
ratingintegerReview rating (0 to 5). READ-ONLY
namestringReviewer name. READ-ONLY
emailstringReviewer email. READ-ONLY
verifiedbooleanShows if the reviewer bought the product or not. READ-ONLY

List all product reviews

This API lets you retrieve all reviews of a product.

GET /wp-json/wc/v1/products/<product_id>/reviews
curl https://example.com/wp-json/wc/v1/products/162/reviews \
-u consumer_key:consumer_secret