Create a request to get product listing page data

This topic shows you how to make a call to the Sitecore Discover Search and Recommendation API to get product listing page (PLP) data in the following scenario:

  • You want to show 24 results on a PLP (n_item = 24).

  • You want to make a call to get data for the first page of the PLP (page_number =1).

  • You want all facets.

  • The user must be able to sort products by customer ratings.

Note

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

To create a request to get PLP data:

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

  2. In the request body, add page context and user context. For page context, include the page uri and locale information (if applicable). For user context, include either the uuid or the user_ID.

    RequestResponse
    {
        "context": {
            "page": {
                "uri": "/womens/memory-foam"
            },
            "user": {
                "uuid": "sampleUUID"
            }
        }
    }
  3. Add widget information. Here, we want all widgets.

    RequestResponse
    {
        "widget": {
            "all": true
        }
    }
  4. Add pagination information. Specify the number of items (n_item) you want to see in one page of search results. Also, specify the page (page_number) you are making the call for.

    RequestResponse
    {
        "n_item": 24,
        "page_number": 1
    }
  5. Add facet information to tell Discover how many facets you want. Here, we want all facets.

    RequestResponse
     {
        "facet": {
            "all": true
        },
    }
  6. Add sort information to tell Discover how you want to sort. Here, we want the customer to sort products by ratings in descending order.

    RequestResponse
    {
        "sort": {
            "value": [
                {
                    "name": "rating",
                    "order": "desc"
                }
            ]
        }
    }
  7. Request product content. Here, 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,