---
title: "Create a request to get recommendation widget data"
slug: "create-a-request-to-get-recommendation-widget-data"
abstract: "How to create a request to get recommendation widget data."
---
# 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](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/integrate-using-discover-rest-apis/integrate-using-the-search-and-recommendation-api/integrating-a-recommendation-widget/the-api-explorer-tab.html "The API Explorer tab") to try out requests and see sample responses.

To create a request to get recommendation widget data:

1. In the header, add [cookies](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/integrate-using-discover-rest-apis/integrate-using-the-search-and-recommendation-api/integrating-a-recommendation-widget/cookies-and-personalization-information.md "Cookies and personalization information") and, if required, [authentication](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/integrate-using-discover-rest-apis/integrate-using-the-search-and-recommendation-api/integrating-a-recommendation-widget/api-authentication-and-authorization.md "API authentication and authorization") details.
2. Add [page context](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/integrate-using-discover-rest-apis/integrate-using-the-search-and-recommendation-api/integrating-a-recommendation-widget/page-context-object.md "Page context object") and [user context](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/integrate-using-discover-rest-apis/integrate-using-the-search-and-recommendation-api/integrating-a-recommendation-widget/user-context-object.md "User context object"). 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`.

    ```JSON
    "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](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/integrate-using-discover-rest-apis/integrate-using-the-search-and-recommendation-api/integrating-a-recommendation-widget/the-batch-request-object.md "The batch request object").

    ```JSON
    "batch": [
            {
                "widget": {
                    "rfkid": "rfkid_31"
                }
            },
            {
                "widget": {
                    "rfkid": "rfkid_32"
                }
            }
    ```

4. Add [pagination information](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/integrate-using-discover-rest-apis/integrate-using-the-search-and-recommendation-api/integrating-a-recommendation-widget/the-content-request-object.md "The content request object"). 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.

    ```JSON
    "n_item": 1,
    "page_number": 1,
    ```

5. Request product [content](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/integrate-using-discover-rest-apis/integrate-using-the-search-and-recommendation-api/integrating-a-recommendation-widget/the-content-request-object.md "The content request object"). In the following example, we want the entire product.

    ```JSON
    "content": {
            "product": {}
    ```

You can see the complete request with all objects put together and the corresponding response in [the sample section](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/integrate-using-discover-rest-apis/integrate-using-the-search-and-recommendation-api/integrating-a-recommendation-widget/sample-request-and-response-to-integrate-a-recommendation-widget.html "Sample request and response to integrate a recommendation widget").