Create a request to get recommendation widget data

This topic shows you how to make a call to the Sitecore Discover Search and Recommendation API to get a recommendation widget, using the following example scenario:

  • You want to add 2 recommendation widgets to a product details page.

  • You want to show 1 item in each recommendation widget (n_item = 1).

  • You want to make a call for the first page of the recommendation widget (page_number = 1).

Note

Use the API explorer to try out requests and see sample responses.

To create a request to get recommendation widget data:

  1. In the header, add cookies and, if required, authentication details.

  2. Add page context and user context. For page context, include at least the page uri, the product_group of the product displayed on the page, the product sku, and locale information (if applicable). For user context, include either the uuid or the user_ID.

    RequestResponse
    "context": {
            "page": {
                "uri": "/magnum-shielding/1-in-chrome-ape-hanger-10-in-rise-handlebars-3hb-0510.p5904622.prd/5904622.sku",
                "locale_country": "us",
                "locale_language": "en",
                "product_group": [
                    "product_p5904622"
                ],
                "sku": [
                    "5493"
                ]
            },
            "user": {
                "uuid": "SampleUUID"
            }
  3. Add widget information. Because you need data for two widgets, pass information as a batch object.

    RequestResponse
     "batch": [
            {
                "widget": {
                    "rfkid": "rfkid_31"
                }
            },
            {
                "widget": {
                    "rfkid": "rfkid_32"
                }
            }
  4. Add pagination information. Specify the number of items (n_item) you want to see on a single widget page. Also, specify the recommendation widget page (page_number) for which you make the call.

    RequestResponse
    "n_item": 1,
    "page_number": 1,
  5. Request product content. In the following example, we want the entire product.

    RequestResponse
        "content": {
            "product": {}

You can see the complete request with all objects put together and the corresponding response in the sample section.

Do you have some feedback for us?

If you have suggestions for improving this article,