ProductSearch resource (Data API 23.2)

Summary

Http Method Resource Description
POST /product_search

Searches for products.

Note: This resource does not return information about product master and product variation relationships. Use the ProductSearch SHOP API resource to retrieve more details about product relationships.

The query attribute specifies a complex query that can be used to narrow down the search. Attributes are grouped into different buckets. These are the list of searchable attributes with their corresponding buckets:

Main:

  • id - String
  • name - String
  • online - SiteSpecific Boolean
  • searchable - SiteSpecific Boolean
  • valid_from - SiteSpefic DateTime
  • valid_to - SiteSpecfic DateTime
  • type - ProductType
  • creation_date - DateTime
  • last_modified - DateTime

Catalog:

  • catalog_id - String

Category:

  • category_id - String

Special:

  • type - {"item", "set, "bundle", "master", "part_of_product_set", "bundled", "variant", "variation_group", "option", "retail_set", "part_of_retail_set"}

The sortable properties are:

  • id - String
  • name - String
  • creation_date - DateTime

When you specify a catalog_id or category_id, only products explicitly assigned to that catalog or category are returned. For example, if a product with variants is assigned to a catalog, but its variants are not, searching on that catalog_id only returns the main product, not the variants. This behavior is different from that of the product search in Business Manager, which returns products that inherit the selected catalog or category assignment.

Only attributes in the same bucket can be joined using a disjunction (OR). For instance, when joining id and catalog_id above, only a conjunction is allowed (AND), whereas id and searchable can be joined using a disjunction because they are in the same bucket. If an attribute is used in a disjunction (OR) that violates this rule, an exception will be thrown.

The product search retrieves additional properties of the product when expansions are used. The available expand attribute values are:

  • 'all' will retrieve all the product properties.
  • 'availability' will retrieve the following properties:
    • ats
    • in_stock
    • online
  • 'categories' will retrieve the following properties:
    • assigned_categories
  • 'images' will retrieve the following properties:
    • image
  • 'all_images' used with images will retrieve the following properties:
    • image
    • image_groups
  • 'prices' will retrieve the following properties:
    • price
    • price_currency
  • 'sets' will retrieve the following properties:
    • set_products
    • product_sets
  • 'bundles' will retrieve the following properties:
    • product_bundles
    • bundled_products

Search Products

Searches for products.

Note: This resource does not return information about product master and product variation relationships. Use the ProductSearch SHOP API resource to retrieve more details about product relationships.

The query attribute specifies a complex query that can be used to narrow down the search. Attributes are grouped into different buckets. These are the list of searchable attributes with their corresponding buckets:

Main:

  • id - String
  • name - String
  • online - SiteSpecific Boolean
  • searchable - SiteSpecific Boolean
  • valid_from - SiteSpefic DateTime
  • valid_to - SiteSpecfic DateTime
  • type - ProductType
  • creation_date - DateTime
  • last_modified - DateTime

Catalog:

  • catalog_id - String

Category:

  • category_id - String

Special:

  • type - {"item", "set, "bundle", "master", "part_of_product_set", "bundled", "variant", "variation_group", "option", "retail_set", "part_of_retail_set"}

The sortable properties are:

  • id - String
  • name - String
  • creation_date - DateTime

When you specify a catalog_id or category_id, only products explicitly assigned to that catalog or category are returned. For example, if a product with variants is assigned to a catalog, but its variants are not, searching on that catalog_id only returns the main product, not the variants. This behavior is different from that of the product search in Business Manager, which returns products that inherit the selected catalog or category assignment.

Only attributes in the same bucket can be joined using a disjunction (OR). For instance, when joining id and catalog_id above, only a conjunction is allowed (AND), whereas id and searchable can be joined using a disjunction because they are in the same bucket. If an attribute is used in a disjunction (OR) that violates this rule, an exception will be thrown.

The product search retrieves additional properties of the product when expansions are used. The available expand attribute values are:

  • 'all' will retrieve all the product properties.
  • 'availability' will retrieve the following properties:
    • ats
    • in_stock
    • online
  • 'categories' will retrieve the following properties:
    • assigned_categories
  • 'images' will retrieve the following properties:
    • image
  • 'all_images' used with images will retrieve the following properties:
    • image
    • image_groups
  • 'prices' will retrieve the following properties:
    • price
    • price_currency
  • 'sets' will retrieve the following properties:
    • set_products
    • product_sets
  • 'bundles' will retrieve the following properties:
    • product_bundles
    • bundled_products

Url

POST https://hostname:port/dw/data/v23_2/product_search?site_id={String}

Formats

json, xml

Authentication

Name Description
OAuth Authentication via OAuth token.

Request Document

SearchRequest

Response Document

ProductSearchResult

Query Parameters

Parameter Type Description Constraints
site_id String The site context.  

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 MalformedSearchParameterException   Indicates the search query is ill-formed.

Sample

REQUEST:
POST /s/-/dw/data/v23_2/product_search HTTP/1.1
Host: example.com
Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c4507367
Accept: application/json

{
    "query" : {
        "text_query": {
            "fields": ["id"],
            "search_phrase": "my-product"
        }
    },
    "expand" : ["prices"],
    "select" : "(**)"
}

RESPONSE:
HTTP/1.1 200 OK
Content-Length: 67
Content-Type: application/json; charset=UTF-8

{
  "_v" : "23.2",
  "count" : 2,
  "hits" :    [
      {
         "_type" : "product",
         "_resource_state" : "860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5",
         "brand" : "Brand",
         "id" : "my-product",
         "link" : "https://example.com/s/-/dw/data/v23_2/products/my-product",
         "long_description" : 
         {
            "default" : "Long Description"
         },
         "manufacturer_name" : "main manufacturer",
         "manufacturer_sku" : "main manufacturer ID",
         "name" : 
         {
            "default" : "Main"
         },
         "online" : 
         {
            "default" : true
         },
         "owning_catalog_id" : "my-catalog",
         "owning_catalog_name" : 
         {
            "default" : "My Catalog"
         },
         "price" : 100.00,
         "price_currency" : "USD",
         "price_per_unit" : 100.00,
         "searchable" : 
         {
            "default" : true
         },
         "short_description" : 
         {
            "default" : "Short Description"
         },
         "type" : 
         {
            "_type" : "product_type",
            "bundled" : true,
            "master" : true,
            "part_of_product_set" : true
         },
         "unit" : "mst",
         "unit_measure" : "each",
         "unit_quantity" : 1,
         "upc" : "WapiMain UPC"
    },
    {
         "_resource_state":"g940fgk4rfmc9ddcu939dx",
         "brand" : "QA",
         "id" : "my-product2",
         "in_stock" : true,
         "link" : "https://example.com/s/-/dw/data/v23_2/products/my-product2",
         "name" : 
         {
            "default" : "Offline Categorized Variant 2"
         },
         "online" : 
         {
            "default" : true
         },
         "searchable" : 
         {
            "default" : true
         },
         "short_description" : 
         {
            "default" : "Offline and categorized variant in offline master."
         },
         "type" : 
         {
            "_type" : "product_type",
            "variant" : true
         }
      }
   ],
  "query" : { "text_query": { "fields": ["id"], "search_phrase": "my-product" } },
  "select": "**",
  "start" : 0,
  "total" : 2
}
X OCAPI versions 15.x and 16.x will be retired on March 31, 2021. For dates and more information, see the OCAPI versioning and deprecation policy and this Knowledge Article.