B2C Commerce Einstein Product Recommendations API

Calls to the Product Recommendation API deliver Einstein recommendations. The API is accessed using a wire adapter to provide data to a Lightning web component. In this case, the Product Recommendation API returns a set of products to populate the Einstein Recommendations component.

The ProductRecommendationsAdapter returns Einstein product recommendations. Implement this wire adapter by importing it from the einsteinAPI module within the commerce namespace (commerce/einsteinAPI) and then declaring its required parameters with the @wire decorator.

Parameters

  • Recommender Name—The name of the recommender. This parameter determines what kind of product results you see. It must be one of the recommender names listed in the Recommender Names and Anchors table.
  • Anchor Type—The anchor type is either PRODUCT, CATEGORY, or NO_CONTEXT. A product recommendation with an anchor type PRODUCT bases its results on the product IDs that you pass.
  • Anchor Value—If the anchor type is PRODUCT, the value is a list of 18-character product IDs. If the anchor type is CATEGORY, the value is a list of 18-character category IDs. If the anchor type is NO_CONTEXT, there’s no anchor value; it can be null or undefined.

Result

  • products—A list of product details.
  • recoUUID—A string representing the unique ID for the recommendation response. Use this value when you trigger the viewReco and clickReco activities.

Constants

  • ANCHOR_TYPE.PRODUCT
  • ANCHOR_TYPE.CATEGORY
  • ANCHOR_TYPE.NO_CONTEXT

Each recommender name requires a specific anchor type and anchor value. For example, if you use the recommender name “similar-products,” the anchor type must be PRODUCT, and the anchor value must be a list of product IDs. This table shows the anchor type and value associated with each recommender name.

Anchor TypeAnchor ValueRecommender Names
NO_CONTEXTAny value that evaluates to false. For example: null or undefined.
  • personalized-for-shopper
  • recently-viewed
  • top-selling
PRODUCTA list of one or more 18-character product IDs. For example: ['01t000000000000001', '01t000000000000002', '01t000000000000003'].
  • complementary-products
  • customers-who-bought-also-bought
  • recently-viewed
  • similar-products
  • upsell
CATEGORYA list of one or more 18-character category IDs. For example: ['0ZG000000000000001', '0ZG000000000000002', '0ZG000000000000003'].
  • most-viewed-by-category
  • recently-viewed
  • top-selling-by-category

See Also