The API Explorer tab
The API Explorer tab on the Developer Resources page of the Sitecore Search is where developers create and run requests against their data. It is a live and interactive way of working with the search and recommendation API. This topic describes some of the many ways you can use this tool.
The API Explorer tab is divided into three panes: the Builder pane, the Request pane, and the Response pane.
Build
In the Build pane, you can enter or select values for an API request.
Your Sitecore Search implementation is configured for pages where each page has widgets that meet your requirements. The URL or the URL pattern configured for a page determines its content. When you select a page, its configured URL or URL pattern is set in the URL input field of the Build pane.
The API Explorer cannot build API requests made by preview search widgets because they are not contained on pages. The Build can only build API requests for pages.
To see your request, click Build. The request is displayed in the Request pane.
Request
In this pane, your request is displayed in JSON format. You can edit the JSON directly in this pane.
The following code is an example of a request.
{
"context": {
"page": {
"uri": "/search"
},
"user": {
"user_id": "12145"
}
},
"widget": {
"rfkid": "rfkid_7"
},
"content": {
"product": {}
}
}
An error indicates the values you must set or update if the request is missing any values relevant to your query.
Click at the top-right of the pane to increase its size.
To export the request, click Copy to Clipboard and select from the following options:
-
Copy as cURL using Sitecore host
-
Copy as cURL using your subdomain
-
Copy as data object to use in your code.
To test your request, click Run. The response is displayed in the Response pane.
To avoid disrupting the search experience, the API is designed to never fail. It always returns the next best set of results based on information available.
Response
The JSON response to your request is displayed in this pane. You can collapse and expand the JSON to see the structure and verify the response. To export the response, click Copy to Clipboard and then click Copy as data object.