---
title: "Calling the Search and Recommendation API"
slug: "calling-the-search-and-recommendation-api"
abstract: "Learn how to send a request to the Sitecore Discover Search and Recommendation API and read responses"
---
# Calling the Search and Recommendation API

Sitecore Discover supports both HTTP and HTTPS protocols for the Search and Recommendation API. You can access the API using the GET or POST methods.

The API accepts requests in the form of JSON objects. All information of inquiry to the API must be in key data. The value of the key can either be a JSON string or a URL encoded JSON string.

## API URL

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

![The API Access tab in Developer Resources with the Search and Recommendation API URL selected.](https://doc.sitecore.com/api/markdown-image/discover/en/developers/discover-developer-guide/images/screenshot-searchandrecapi.png)

## API methods

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

The following table describes the required key:

| Key | Data type | Description |
| --- | --- | --- |
| `data` | <JSON string> OR <url encoded JSON string> | A JSON string that represents the request.<br><br>If passed as a `GET` query parameter, the JSON object is HTML decoded before processing the request. |

## Examples

The following shows an example of a GET request to the Search and Recommend API:

```HTTP
GET {API_URL}?data={<your_key_value_data>}
```

The following shows an example of a POST request to the Search and Recommend API:

```HTTP
POST {API_URL}
{
  "data": "{<your_key_value_data>}"
}
```

The following shows an example in Python using the Requests library:

```Python
import requests
import json

url = 'API_URL'
data = {
    "data": '{"query": {"keyphrase": ["example"]},"content": {}}'
}

response = requests.post(url, params=data)
print json.loads(response.text)
```

## Reading responses

Within the [content response object](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/integrate-using-discover-rest-apis/integrate-using-the-search-and-recommendation-api/the-content-response-object.md "The content response object"), there is a nested `product` and then `value` object. You can get the information you need to populate one product slot from the keys and values in the `value` object.

The sample responses for [search page](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/integrate-using-discover-rest-apis/integrate-using-the-search-and-recommendation-api/sample-request-and-response-to-integrate-a-search-page-widget.md "Sample request and response to integrate a search page widget"), product listing page, [recommendation widget](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/integrate-using-discover-rest-apis/integrate-using-the-search-and-recommendation-api/sample-request-and-response-to-integrate-a-recommendation-widget.md "Sample request and response to integrate a recommendation widget"), and [preview search widget](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/integrate-using-discover-rest-apis/integrate-using-the-search-and-recommendation-api/sample-request-and-response-to-integrate-a-preview-search-widget.md "Sample request and response to integrate a preview search widget") integration have more information.

The following code snippet shows a partial sample response with the `content` response object:

```JSON
{
	"content": {
		"product": {
			"total_item": 1131,
			"n_item": 1,
			"value": [{
				"division_name": "CALI",
				"prod_color_count": "5",
				"color": "SLT",
				"price": "65.00",
				"category_names": [
					"Women",
					"Breathable",
					"Sandals",
					"Shoes",
					"Website Premieres",
					"Stretch Fit",
					"Arch Fit",
					"Women-shop-all"
				],
				"sku_url": "/women/shoes/arch-fit---city-catch/119236_SLT.html",
				"swatch_index": 0,
				"variation_product_id": "119236_SLT",
				"brands": [
					"Arch Fit"
				],
				"swatch": [{
					"swatch_landing_url": "/women/shoes/<URL>.html",
					"sku_url": "/women/shoes/<URL>.html",
					"color": "SLT",
					"swatch_image_url": "https://<url>",
					"swatch_style": "#000000",
					"primary_color": "BLUE",
					"sku_image_url": "https://"
				}],
				"id": 997986357,
				"webwidth_flag": "0",
				"size": "7.0",
				"sku": "195204519462",
				"skuid": 1816486109,
				"color_swatch_show_count": 2,
				"name": "Women's Arch Fit - City Catch",
				"color_swatch": [{
					"swatch_landing_url": "/women/shoes/<url>.html",
					"color": "SLT",
					"swatch_style": "#000000",
					"primary_color": "BLUE",
					"swatch_image_url": ""
				}],
				"style_num": "119236",
				"original_name": "Arch Fit - City Catch ",
				"url": "/women/shoes/<url>",
				"image_url": "https://<url>",
				"final_price": "65.00",
				"primary_color": "BLUE",
				"product_group": "119236",
				"brand": "Arch Fit",
				"sku_image_url": "https://<url>",
				"thumbnail_image_url": "https://<url>"
			}]
		}
	}
}
```