Rest API

Sensei requests are JSON objects sent to an end-point via HTTP POST


Rest end-point

Every Sensei node has a rest end-point at the /sensei path listening on the broker port, specified in the file, e.g. = 8080
An example of the end-point is http://localhost:8080/sensei

Sensei Request

The request API is modeled closely after the ElasticSearch Query DSL.

A Sensei Request is represented as a JSON object, see reference.

		  "query" : {
		    "query_string" : { 
		      "query" : "cool car"

		  "selections" : [
		      "term" : "color",
		      "value" : "red"
and can be POSTed to the Rest end-point, e.g.

curl -X -POST -d '{"query":{"query_string" : {"query":"cool car"}},"selections": [{"term":"color","value":"red"}]}' 'http://localhost:8080/sensei'


The following example shows how to make an ajax call to a Sensei rest end-point in a web page using jquery.

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> 
  <html xmlns="">

		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<script src=""></script>
		<script type="text/javascript">
		  var url = "http://localhost:8080/sensei"
		  var senseiReq = {};
		  senseiReq.query = {};
		  senseiReq.query.query_string = {"query" : "cool car"};
		  senseiReq.selections = [{"term":"color","value":"red"}];
		  // cross-domain is allowed by the Sensei Rest end-point
		  $.post("http://localhost:8080/sensei", JSON.stringify(senseiReq),
		   function(result) {

Query via BQL

It is also possible to query a Sensei cluster using BQL.

Simply post to the above Rest end-point with a JSON object containing a bql query, example:

  "bql":"select color where category in ('van','exotic') order by price"

Get using primary keys

Another common query Sensei support is Get/GetAll using UIDs.

Given a list of UIDs, encode them into a JSON array, e.g.

and post to the end-point /sensei/get, e.g. http://localhost:8080/sensei/get