Skip to main content

Calling the Search and Recommendation API

Abstract

Learn how to send a request to the Search and Recommendation API

Sitecore Search supports the HTTPS protocol for the Search and Recommendation API. The API accepts requests in the form of JSON objects.

You can get the API URL in the Customer Engagement Console (CEC), in Developer Resources, on the API Access tab.

You can use the GET or POST method to send requests to the Search and Recommendation API.

You must authenticate to access Sitecore Search REST APIs.

When you send requests to the API, you must include these objects to get a response:

  • rfk.domainId - add this to the header of your request to specify the domain for which you want to make the request.

  • widget.items.rfkd_id - add this key to specify the rfkid of the widget you want to call.

  • widget.items.entity - add this key to specify the entity you want to use for this request.

  • context.locale - If you have a multi-locale domain, add this object to specify the country and language you want to use for the results.

When you send requests to the API, we recommend that you add the following object:

  • context.user.uuid - an anonymous unique identifier of the visitor who visits the page. Add this object so that Sitecore Search can give your visitors relevant search results. If you do not pass the uuid, the search results you see are not tailored to that specific visitor. To learn how to generate a uuid, see Using a UUID to track site visitors.

The following is a sample CURL POST request to the Search and Recommendation API to get content for the key phrase cloud computing:

{
    "widget": {
        "items": [
            {
                "rfk_id": "rfkid_7",
                "entity": "content",
                "search": {
                    "content": {},
                    "query": {
                        "keyphrase": "cloud computing"
                    }
                }
            }
        ]
    },
    "context": {
        "locale": {
            "country": "us",
            "language": "en"
        }
    }
}