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_created_gmtdate-timeThe date the product was created, as GMT. READ-ONLY
date_modifieddate-timeThe date the product was last modified, in the site's timezone. READ-ONLY
date_modified_gmtdate-timeThe date the product was last modified, as GMT. READ-ONLY
typestringProduct type. Options: simple, grouped, external and variable. Default is simple.
statusstringProduct status (post status). Options: draft, pending, private and publish. Default is publish.
featuredbooleanFeatured product. Default is false.
catalog_visibilitystringCatalog visibility. Options: visible, catalog, search and hidden. Default is visible.
descriptionstringProduct description.
short_descriptionstringProduct short description.
skustringUnique identifier.
pricestringCurrent product price. READ-ONLY
regular_pricestringProduct regular price.
sale_pricestringProduct sale price.
date_on_sale_fromdate-timeStart date of sale price, in the site's timezone.
date_on_sale_from_gmtdate-timeStart date of sale price, as GMT.
date_on_sale_todate-timeEnd date of sale price, in the site's timezone.
date_on_sale_to_gmtdate-timeEnd date of sale price, as GMT.
price_htmlstringPrice formatted in HTML. 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. Default is false.
downloadablebooleanIf the product is downloadable. Default is false.
downloadsarrayList of downloadable files. See Product - Downloads properties
download_limitintegerNumber of times downloadable files can be downloaded after purchase. Default is -1.
download_expiryintegerNumber of days until access to downloadable files expires. Default is -1.
external_urlstringProduct external URL. Only for external products.
button_textstringProduct external button text. Only for external products.
tax_statusstringTax status. Options: taxable, shipping and none. Default is taxable.
tax_classstringTax class.
manage_stockbooleanStock management at product level. Default is false.
stock_quantityintegerStock quantity.
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. Options: no, notify and yes. Default is no.
backorders_allowedbooleanShows if backorders are allowed. READ-ONLY
backorderedbooleanShows if the product is on backordered. READ-ONLY
sold_individuallybooleanAllow one item to be bought in a single order. Default is false.
weightstringProduct weight.
dimensionsobjectProduct dimensions. See Product - 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_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. READ-ONLY
upsell_idsarrayList of up-sell products IDs.
cross_sell_idsarrayList of cross-sell products IDs.
parent_idintegerProduct parent ID.
purchase_notestringOptional note to send the customer after purchase.
categoriesarrayList of categories. See Product - Categories properties
tagsarrayList of tags. See Product - Tags propertiesarrayList of images. See Product - Images properties
attributesarrayList of attributes. See Product - Attributes properties
default_attributesarrayDefaults variation attributes. See Product - Default attributes properties
variationsarrayList of variations IDs. READ-ONLY
grouped_productsarrayList of grouped products ID.
menu_orderintegerMenu order, used to custom sort products.
meta_dataarrayMeta data. See Product - Meta data properties

Product - Downloads properties

AttributeTypeDescription
idstringFile ID.
namestringFile name.
filestringFile URL.

Product - Dimensions properties

AttributeTypeDescription
lengthstringProduct length.
widthstringProduct width.
heightstringProduct height.

Product - Categories properties

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

Product - Tags properties

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

Product - Images properties

AttributeTypeDescription
idintegerImage ID.
date_createddate-timeThe date the image was created, in the site's timezone. READ-ONLY
date_created_gmtdate-timeThe date the image was created, as GMT. READ-ONLY
date_modifieddate-timeThe date the image was last modified, in the site's timezone. READ-ONLY
date_modified_gmtdate-timeThe date the image was last modified, as GMT. READ-ONLY
srcstringImage URL.
namestringImage name.
altstringImage alternative text.
positionintegerImage position. 0 means that the image is featured.

Product - Attributes properties

AttributeTypeDescription
idintegerAttribute ID.
namestringAttribute name.
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.

Product - Default attributes properties

AttributeTypeDescription
idintegerAttribute ID.
namestringAttribute name.
optionstringSelected attribute term name.

Product - Meta data properties

AttributeTypeDescription
idintegerMeta ID. READ-ONLY
keystringMeta key.
valuestringMeta value.

Create a product

This API helps you to create a new product.

POST /wp-json/wc/v2/products

Example of how to create a simple product:

curl -X POST https://example.com/wp-json/wc/v2/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/v2/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"
}
]
}'

Retrieve a product

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

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

List all products

This API helps you to view all the products.

GET /wp-json/wc/v2/products
curl https://example.com/wp-json/wc/v2/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. Default is view.
pageintegerCurrent page of the collection. Default is 1.
per_pageintegerMaximum number of items to be returned in result set. Default is 10.
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.
excludearrayEnsure result set excludes specific IDs.
includearrayLimit result set to specific ids.
offsetintegerOffset the result set by a specific number of items.
orderstringOrder sort attribute ascending or descending. Options: asc and desc. Default is desc.
orderbystringSort collection by object attribute. Options: date, id, include, title and slug. Default is date.
parentarrayLimit result set to those of particular parent IDs.
parent_excludearrayLimit result set to all items except those of a particular parent ID.
slugstringLimit result set to products with a specific slug.
statusstringLimit result set to products assigned a specific status. Options: any, draft, pending, private and publish. Default is any.
typestringLimit result set to products assigned a specific type. Options: simple, grouped, external and variable.
skustringLimit result set to products with a specific SKU.
featuredbooleanLimit result set to featured products.
categorystringLimit result set to products assigned a specific category ID.
tagstringLimit result set to products assigned a specific tag ID.
shipping_classstringLimit result set to products assigned a specific shipping class ID.
attributestringLimit result set to products with a specific attribute.
attribute_termstringLimit result set to products with a specific attribute term ID (required an assigned attribute).
tax_classstringLimit result set to products with a specific tax class. Default options: standard, reduced-rate and zero-rate.
in_stockbooleanLimit result set to products in stock or out of stock.
on_salebooleanLimit result set to products on sale.
min_pricestringLimit result set to products based on a minimum price.
max_pricestringLimit result set to products based on a maximum price.

Update a product

This API lets you make changes to a product.

PUT /wp-json/wc/v2/products/<id>
curl -X PUT https://example.com/wp-json/wc/v2/products/794 \
-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/v2/products/<id>
curl -X DELETE https://example.com/wp-json/wc/v2/products/794?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/v2/products/batch
curl -X POST https://example.com/wp-json/wc/v2/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": 799,
"default_attributes": [
{
"id": 6,
"name": "Color",
"option": "Green"
},
{
"id": 0,
"name": "Size",
"option": "M"
}
]
}
],
"delete": [
794
]
}'

Retrieve product reviews

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

GET /wp-json/wc/v2/products/<product_id>/reviews/<id>
curl https://example.com/wp-json/wc/v2/products/22/reviews/5 \
-u consumer_key:consumer_secret

Product review properties

AttributeTypeDescription
idintegerUnique identifier for the resource. READ-ONLY
reviewstringThe content of the review. MANDATORY
date_createddate-timeThe date the review was created, in the site's timezone.
date_created_gmtdate-timeThe date the review was created, as GMT.
ratingintegerReview rating (0 to 5).
namestringReviewer name. MANDATORY
emailstringReviewer email. MANDATORY
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/v2/products/<product_id>/reviews
curl https://example.com/wp-json/wc/v2/products/22/reviews \
-u consumer_key:consumer_secret