The Products REST API endpoint is part of the WooCommerce Product Search extension.
Provide all products or those that match a specified set of search and filter constraints.
HTTP Request
↑ Back to topGET /wp-json/wps/v1/products
Parameters
↑ Back to topThe endpoint allows to specify the parameters described below.
Parameter | Type | Description |
---|---|---|
status | string | Limit the results by post status. Options: publish for unprivileged requests. Privileged requests allow publish , any , future , trash , draft , pending and private but may not always yield results. |
orderby | string | Sort products by indicated option. Options: '' (empty string), date , id , menu_order , modified , name , price , price-desc , popularity , rand (only privileged requests), rating , relevance , sku , slug and title . Default is menu_order . |
order | string | Sort order. Options: asc and desc . Default is asc . |
q | string | Search query string. |
search | string | Search query string (this is an alias for q ). |
title | boolean | Search in titles. Default is true . |
excerpt | boolean | Search in excerpts. Default is true . |
content | boolean | Search in content. Default is true . |
sku | boolean | Search in SKUs. Default is true . |
categories | boolean | Search in related categories. Default is true . |
tags | boolean | Search in related tags. Default is true . |
attributes | boolean | Search in related attributes. Default is true . |
variations | boolean | Search in variations. Default is true . |
page | integer | Current results page. Default is 1 . |
per_page | integer | Results per page. Default is 10 . Maximum is 100 for unprivileged requests. |
offset | integer | Offset results by as many. Minimum is 0 . |
limit | integer | Limit to a maximum number of results. Maximum is 100 for unprivileged requests. |
min_price | string | Limit results based on a minimum price. |
max_price | string | Limit results based on a maximum price. |
sale | boolean | Limit results based on whether they are on sale or not on sale. |
stock | string | array | Limit results based on whether they are in stock, out of stock or available on backorder. Options: instock , outofstock and onbackorder . |
featured | boolean | Limit results based on whether they are featured. |
visibility | string | Limit results based on their visibility. Options: visible , catalog , search , hidden , exclude-from-search and exclude-from-catalog . |
t | string | array | json | Limit results to those related to terms. Details are provided in the section The ‘t’ Parameter Format below. |
include_variations | boolean | Include variations in results. Default is false . |
The ‘t’ Parameter Format
↑ Back to topThe t
parameter is used to request products which are related to certain taxonomy terms. This allows to filter the products based on specific product categories, product tags and any product attributes and any combinations of those.
The parameter can be specified in array form or as JSON. Depending on the form and the desired terms, the sub-parameters t
, op
and taxonomy
are used.
When provided as an array, the array keys indicate the taxonomy, the sub-parameters indicate the desired terms via t
and the operation via op
.
If provided as JSON, the taxonomy can be used as key to the set of parameters, or provided as one of the parameters. The latter form is the most flexible and allows to request several instances of the same and/or different taxonomies.
If op
is omitted, it defaults to or
.
The parameter can be specified as JSON …
t={json}
… or using an array form:
t[{taxonomy}][t]={term}*
t[{taxonomy}[op]=and|or|not
The JSON form is more flexible and can be shorter. In the examples below, we provide all three forms when possible. Please note that for certain expressions, only the JSON format with the taxonomy
parameter is suitable as there are certain constraints that cannot be specified otherwise.
Example – to request products that are related to the Videogames product category:
- Array form :
t[product_cat][t]=videogames
- JSON form using taxonomy as key :
t={"product_cat":{"t":"videogames"}}
- JSON form using taxonomy as parameter :
t=[{"taxonomy":"product_cat","t":"videogames"}]
Example – to request products that are tagged as Herbs or Vegetables:
- JSON form using taxonomy as key :
t[product_tag][t]=herbs,vegetables
- JSON form using taxonomy as key :
t={"product_tag":{"t":"herbs,vegetables"}}
- JSON form using taxonomy as parameter :
t=[{"taxonomy":"product_tag","t":["herbs","vegetables"]}]
Example – to request products that are tagged as Spicy and Fruity:
- Array form :
t[product_tag][t]=spicy,fruity&t[product_tag][op]=and
- JSON form using taxonomy as key :
t={"product_tag":{"t":["spicy","fruity"],"op":"and"}}
- JSON form using taxonomy as parameter :
t=[{"taxonomy":"product_cat","t":["spicy","fruity"],"op":"and"}]
Example – to request products that are in the Men category whose size is XL and whose color is red:
- Array form :
t[product_cat][t]=men&t[pa_size][t]=xl&t[pa_color][t]=red
- JSON form using taxonomy as key :
t={"product_cat":{"t":"red"},"pa_size":{"t":"xl"},"pa_color":{"t":"red"}}
- JSON form using taxonomy as parameter :
t=[{"taxonomy":"product_cat","t":"men"},{"taxonomy":"pa_size","t":"xl"},{"taxonomy":"pa_color","t":"red"}]
Prettier formatting makes the use of the above JSON format using the taxonomy
parameter clear:
t=[
{
"taxonomy":"product_cat",
"t":"men"
},
{
"taxonomy":"pa_size",
"t":"xl"
},
{
"taxonomy":"pa_color",
"t":"red"
}
]
These examples illustrate simple cases, there are no restrictions on the number of taxonomies and terms that can be provided.
JSON Response
↑ Back to topThe response to a request to the products
endpoint will contain detailed product data for the products that match the requested parameters.
Here is an example response to a request /wp-json/wps/v1/products
based on the defaults. A single product data set is shown and additional entries that would be included have been omitted for clarity. This data provided for products is also included with the shop endpoint in the corresponding section of its JSON response. See the section REST API – Shop for details in its example.
[
{
"id": 353,
"name": "Beach Top",
"slug": "beach-top",
"permalink": "https://example.com/product/beach-top/",
"type": "variable",
"featured": false,
"description": "<p>Our exclusive Beach Top is an essential stylish piece in your closet. With thin straps and small precious details in front, this garment has a refined feminine look. This one is made from raw silk with a smooth yet textured and refined character.</p>\n<p>Material : 100% Silk</p>\n",
"short_description": "<p>A stylish exclusive beach top.</p>\n",
"sku": "women-top",
"price": "30",
"price_html": "<span class=\"woocommerce-Price-amount amount\"><bdi><span class=\"woocommerce-Price-currencySymbol\">$</span>30.00</bdi></span>",
"on_sale": false,
"purchasable": true,
"virtual": false,
"downloadable": false,
"external_url": "",
"button_text": "",
"stock_quantity": null,
"backorders_allowed": false,
"backordered": false,
"sold_individually": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_required": true,
"shipping_class": "",
"shipping_class_id": 0,
"reviews_allowed": true,
"average_rating": "0.00",
"rating_count": 0,
"upsell_ids": [],
"cross_sell_ids": [],
"parent_id": 0,
"categories": [
{
"id": 68,
"name": "Tops",
"slug": "tops"
}
],
"tags": [],
"images": [
{
"id": 371,
"date_created": "2023-11-15T14:20:32",
"date_created_gmt": "2023-11-15T14:20:32",
"date_modified": "2023-11-15T14:20:32",
"date_modified_gmt": "2023-11-15T14:20:32",
"src": "https://example.com/wp-content/uploads/2023/11/atikh-bana-113633-unsplash-1000x1600-1.jpg",
"name": "atikh-bana-113633-unsplash-1000×1600-1.jpg",
"alt": "",
"featured": true
}
],
"attributes": [
{
"id": 1,
"name": "Color",
"slug": "pa_color",
"position": 0,
"visible": false,
"variation": true,
"options": [
"Orange",
"Yellow"
]
},
{
"id": 2,
"name": "Size",
"slug": "pa_size",
"position": 1,
"visible": true,
"variation": true,
"options": [
"L",
"M",
"S",
"XL"
]
}
],
"default_attributes": [],
"variations": [
{
"id": 354,
"permalink": "https://example.com/product/beach-top/?attribute_pa_color=yellow&attribute_pa_size=s",
"sku": "women-top-s-yellow",
"price": "30",
"regular_price": "30",
"sale_price": "",
"on_sale": false,
"purchasable": true,
"virtual": false,
"downloadable": false,
"stock_quantity": null,
"stock_status": "instock",
"backorders_allowed": false,
"backordered": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_class": "",
"shipping_class_id": 0,
"attributes": [
{
"id": 1,
"name": "Color",
"slug": "pa_color",
"option": "Yellow"
},
{
"id": 2,
"name": "Size",
"slug": "pa_size",
"option": "S"
}
]
},
{
"id": 355,
"permalink": "https://example.com/product/beach-top/?attribute_pa_color=yellow&attribute_pa_size=m",
"sku": "women-top-m-yellow",
"price": "30",
"regular_price": "30",
"sale_price": "",
"on_sale": false,
"purchasable": true,
"virtual": false,
"downloadable": false,
"stock_quantity": null,
"stock_status": "instock",
"backorders_allowed": false,
"backordered": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_class": "",
"shipping_class_id": 0,
"attributes": [
{
"id": 1,
"name": "Color",
"slug": "pa_color",
"option": "Yellow"
},
{
"id": 2,
"name": "Size",
"slug": "pa_size",
"option": "M"
}
]
},
{
"id": 356,
"permalink": "https://example.com/product/beach-top/?attribute_pa_color=yellow&attribute_pa_size=l",
"sku": "women-top-l-yellow",
"price": "30",
"regular_price": "30",
"sale_price": "",
"on_sale": false,
"purchasable": true,
"virtual": false,
"downloadable": false,
"stock_quantity": null,
"stock_status": "instock",
"backorders_allowed": false,
"backordered": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_class": "",
"shipping_class_id": 0,
"attributes": [
{
"id": 1,
"name": "Color",
"slug": "pa_color",
"option": "Yellow"
},
{
"id": 2,
"name": "Size",
"slug": "pa_size",
"option": "L"
}
]
},
{
"id": 357,
"permalink": "https://example.com/product/beach-top/?attribute_pa_color=yellow&attribute_pa_size=xl",
"sku": "women-top-xl-yellow",
"price": "30",
"regular_price": "30",
"sale_price": "",
"on_sale": false,
"purchasable": true,
"virtual": false,
"downloadable": false,
"stock_quantity": null,
"stock_status": "instock",
"backorders_allowed": false,
"backordered": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_class": "",
"shipping_class_id": 0,
"attributes": [
{
"id": 1,
"name": "Color",
"slug": "pa_color",
"option": "Yellow"
},
{
"id": 2,
"name": "Size",
"slug": "pa_size",
"option": "XL"
}
]
},
{
"id": 358,
"permalink": "https://example.com/product/beach-top/?attribute_pa_color=orange&attribute_pa_size=s",
"sku": "women-top-s-orange",
"price": "30",
"regular_price": "30",
"sale_price": "",
"on_sale": false,
"purchasable": true,
"virtual": false,
"downloadable": false,
"stock_quantity": null,
"stock_status": "instock",
"backorders_allowed": false,
"backordered": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_class": "",
"shipping_class_id": 0,
"attributes": [
{
"id": 1,
"name": "Color",
"slug": "pa_color",
"option": "Orange"
},
{
"id": 2,
"name": "Size",
"slug": "pa_size",
"option": "S"
}
]
},
{
"id": 359,
"permalink": "https://example.com/product/beach-top/?attribute_pa_color=orange&attribute_pa_size=m",
"sku": "women-top-m-orange",
"price": "30",
"regular_price": "30",
"sale_price": "",
"on_sale": false,
"purchasable": true,
"virtual": false,
"downloadable": false,
"stock_quantity": null,
"stock_status": "instock",
"backorders_allowed": false,
"backordered": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_class": "",
"shipping_class_id": 0,
"attributes": [
{
"id": 1,
"name": "Color",
"slug": "pa_color",
"option": "Orange"
},
{
"id": 2,
"name": "Size",
"slug": "pa_size",
"option": "M"
}
]
},
{
"id": 360,
"permalink": "https://example.com/product/beach-top/?attribute_pa_color=orange&attribute_pa_size=l",
"sku": "women-top-l-orange",
"price": "30",
"regular_price": "30",
"sale_price": "",
"on_sale": false,
"purchasable": true,
"virtual": false,
"downloadable": false,
"stock_quantity": null,
"stock_status": "instock",
"backorders_allowed": false,
"backordered": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_class": "",
"shipping_class_id": 0,
"attributes": [
{
"id": 1,
"name": "Color",
"slug": "pa_color",
"option": "Orange"
},
{
"id": 2,
"name": "Size",
"slug": "pa_size",
"option": "L"
}
]
},
{
"id": 361,
"permalink": "https://example.com/product/beach-top/?attribute_pa_color=orange&attribute_pa_size=xl",
"sku": "women-top-xl-orange",
"price": "30",
"regular_price": "30",
"sale_price": "",
"on_sale": false,
"purchasable": true,
"virtual": false,
"downloadable": false,
"stock_quantity": null,
"stock_status": "instock",
"backorders_allowed": false,
"backordered": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_class": "",
"shipping_class_id": 0,
"attributes": [
{
"id": 1,
"name": "Color",
"slug": "pa_color",
"option": "Orange"
},
{
"id": 2,
"name": "Size",
"slug": "pa_size",
"option": "XL"
}
]
}
],
"grouped_products": [],
"menu_order": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wps/v1/products/353"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wps/v1/products"
}
]
}
},
... (further entries omitted)
]
This and related sections will be further enhanced with information and examples shortly. If you are a developer and have questions on the use of the REST API for your components or App, you can reach out and Contact Support for the extension.