Products

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 top

GET /wp-json/wps/v1/products

Parameters

↑ Back to top

The endpoint allows to specify the parameters described below.

ParameterTypeDescription
statusstringLimit 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.
orderbystringSort 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.
orderstringSort order. Options: asc and desc. Default is asc.
qstringSearch query string.
searchstringSearch query string (this is an alias for q).
titlebooleanSearch in titles.
Default is true.
excerptbooleanSearch in excerpts.
Default is true.
contentbooleanSearch in content.
Default is true.
skubooleanSearch in SKUs.
Default is true.
categoriesbooleanSearch in related categories.
Default is true.
tagsbooleanSearch in related tags.
Default is true.
attributesbooleanSearch in related attributes.
Default is true.
variationsbooleanSearch in variations.
Default is true.
pageintegerCurrent results page.
Default is 1.
per_pageintegerResults per page.
Default is 10. Maximum is 100 for unprivileged requests.
offsetintegerOffset results by as many. Minimum is 0.
limitintegerLimit to a maximum number of results. Maximum is 100 for unprivileged requests.
min_pricestringLimit results based on a minimum price.
max_pricestringLimit results based on a maximum price.
salebooleanLimit results based on whether they are on sale or not on sale.
stockstring | arrayLimit results based on whether they are in stock, out of stock or available on backorder. Options: instock, outofstock and onbackorder.
featuredbooleanLimit results based on whether they are featured.
visibilitystringLimit results based on their visibility. Options: visible, catalog, search, hidden, exclude-from-search and exclude-from-catalog.
tstring | array | jsonLimit results to those related to terms.

Details are provided in the section The ‘t’ Parameter Format below.
include_variationsbooleanInclude variations in results. Default is false.

The ‘t’ Parameter Format

↑ Back to top

The 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 top

The 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.

Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.