Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Product recommendations response

Describes the product recommendations received in a response, generated by the Optimizely recommendations engine.

The Optimizely Recommendations API returns a list of product recommendations in the message.

The contents are returned in the smartRecs element at the root of the response JSON. It contains the product recommendations generated by the Optimizely recommendations engine. These product recommendations are grouped by widget.

The value of smartRecs is a list of product recommendation widget elements. These elements have the following properties:

Parameters Description and usage
campaignId [String]

The ID of the widget campaign. This is used for validation.
"campaignId" : "k3Rw892i"
campaignName [String]

The name of the widget campaign. This is used for validation.
"campaignName" : "Packaging slip"
widgets [List]

The list of widgets in the campaign.
"widgets" : [{…},{…},…]
  widgetId [String]

The ID of the widget.
"widgetId" : "08Ppq3ca"
  widgetName [String]

The name of the widget.
"widgetId" : "middlejson"
  alias [String]

The alias name of the widget. Multiple widgets can share the same alias.
"alias" : "Packaging slip (4 recs)"
  recs A list of product recommendations.
"recs" : [{…},{…},{…},…]
    img [String]

URL of the product image.
"img" : "http://www.retailer.com/img/RC678_size_small"
    title [String]

Product title.
"title" : "Levis Washed Jeans"
    url [String]

URL to the product page for the item.
"url" : "http://www.retailer.com/product/RC678.html"
    refCode [String]

Product reference code.
"refCode" : "RC678"
    prices A map in which the key will be the currency name (such as USD, GBP, and so on) and the value a map with unitPrice and salePrice properties. For example:
"prices"  : {
              "GBP" : {
                        "unitPrice" : 52.00,
                        "salePrice" : 40.00
                      }
            }
      unitPrice [Number]

The price per unit of the item.
      salePrice [Number]

The sale price of the item.
    attributes A list of attributes and their values. Attributes required in the request.
"attributes" : { "colour" : "washed blue", … }

In the request, you can configure the output details of the recommended product by the recContent request parameter.

Response examples

The following example shows three product recommendations returned for one widget with full product details, which is the default behavior when recContent is omitted or has value full:

{  
      "status"    : "OK",
      "smartRecs" : [{  
        "campaignId"   : "k3Rw892i",
        "campaignName" : "Packaging slip",
        "widgets"      : {  
            "widgetId"   : "08Ppq3ca",
            "widgetName" : "middlejson",
            "alias"      : "Packaging slip (4 recs)",
            "recs"       : [{  
               "img"        : "http://www.retailer.com/img/RC678_size_small",
               "title"      : "Levis Washed Jeans"
               "url"        : "http://www.retailer.com/product/RC678.html",
               "refCode"    : "RC678",
               "prices"     : {  
                 "GBP" : {  
                   "unitPrice" : 52.00,  
                   "salePrice" : 40.00
                 }
               },
               "attributes" : {  
                 "colour" : "dirty blue"
               }
             },
             {  
               "img"        : "http://www.retailer.com/img/RC910_size_small",
               "title"      : "Levis Dirty Jeans",
               "url"        : "http://www.retailer.com/product/RC910.html",
               "refCode"    : "RC910",
               "prices"     : {  
                 "GBP" : {  
                   "unitPrice" : 54.95,  
                   "salePrice" : 43.95
                 }
               },
               "attributes" : {  
                 "colour" : "washed blue"
               }
             },
             {  
               "img"        : "http://www.retailer.com/img/RC101_size_small",
               "title"      : "Levis Legless Jeans",
               "url"        : "http://www.retailer.com/product/RC101.html",
               "refCode"    : "RC101",
               "prices"     : {  
                 "GBP" : {  
                   "unitPrice" : 39.95,
                   "salePrice" : 39.95
                 }
               },
               "attributes" : {  
                 "colour" : "just blue"
               }
             }]
          }
     }],
    }

This is the returned result when recContent property is set to refCodeOnly:

{  
      "status"    : "OK",
      "smartRecs" : [  
       {  
         "campaignId"   : "k3Rw892i",
         "campaignName" : "Packaging slip",
         "widgets"      : {  
           "widgetId"   : "08Ppq3ca",
           "widgetName" : "middlejson",
           "alias"      : "Packaging slip (4 recs)",
           "recs"       : [  
             {  
               "refCode"    : "RC678",
               "attributes" : {"colour" : "dirty blue"}
             },
             {  
               "refCode"    : "RC910",
               "attributes" : {"colour" : "washed blue"}
             },
             {  
               "refCode"    : "RC101",
               "attributes" : {"colour" : "just blue"}
             }
           ]
         }
       }
     ],
    }