EasyQuery Server API

About EasyQuery Server

EasyQuery Server is a specification of the server-side API which handles the requests from the client-side EasyQuery components. This API include a few endpoints which allow you (as a developer) to implement some basic scenarios of advaced database search, data filtering or adhoc reporting.

The only implementation of EQS API is available for now as a part EasyQuery for ASP.NET Core library.

Endpoints

GetModel

GET /models/{modelId}

Returns the model by its ID

GetQuery

GET /models/{modelId}/queries/{queryId} Returns the query by model's ID and query ID

SaveQuery

PUT /models/{modelId}/queries/{queryId} Saves the query defined by modelId and queryId to the storage on the server. The content of the request is a JSON object which contains the query definition:

{
  "query": {
	    "id": "MyQueryID",
			.   .   .   .  .
	}
}

NewQuery

POST /models/{modelId}/queries Creates a new query for the model defined in modelId and returns it back to the client The content of the request is a JSON object which might contain the query definition (including the preferable ID and name of the new query). If there is no query property in the request content - a default query with some randome ID will be created.

{
  "query": {
	    "id": "MyQueryID",
			.   .   .   .  .
	}
}

RemoveQuery

DELETE /models/{modelId}/queries/{queryId}

GetQueryList

GET /models/{modelId}/queries Returns the list of the queries for specified model (modelId) available for the current user. The response is a JSON object with the list of query definitions:

[
  {
	   "id":"Query1ID",
		  .   .   .   .  
	},
	{
	  "id":"Query2ID",
		  .   .   .   . 
  },
	  .   .   .   .   .
]

SyncQuery

POST /models/{modelId}/queries/{queryId}/sync Synchronizes the changes made in the query on the client-side with the server. The content of the request is a JSON object which contains the query definition.

{
  "query": {
	    "id": "MyQueryID",
			.   .   .   .  .
	}
}

ExecuteQuery

POST /models/{modelId}/queries/{queryId}/execute Executes the query passed in the request body and returns the result set in a format, compatible with Googles DataTable. Here modelId defines the model this query belongs to and can be uses on the server side to specify the database and connection to it (if it's a multi-database application). queryId parameter defines the ID of the query which is going to be executed. The content of the request, as usual, is a JSON object which contains the query definition. Additionally, it might contain some extra options like the preferrable SQL syntax and the page number (in case we are using paging). Here is an example:

{
  "query": {
	    "id": "MyQueryID",
			.   .   .   .  .
	},
	"options": {
	  "sqlOptions": {
		  "SelectDistinct": true
		}, 
		"page": 4
	}
}

GetValueList

GET /models/{modelId}/valuelists/{editorId} Get the list of values by the model specified via modelId parameter and the value editor specified via editorId. The response is a JSON object that contains the list of object with id and text properties each. Example:

{
  "result":"ok",
	"values":[
	  {"id":"SouthAmerica", "text": "South America", items: [
	    {"id":"AR","text":"Argentina"},
			   .    .    .    .    .
	  ]},
	  {"id":"Europe", "text": "Europe", items: [
	    {"id":"AT","text":"Austria"},
			   .    .    .    .    .
	  ]},
		.    .    .    .    .    .
	]
}

As you can see the result list can be hirerachical (so, each item can include sub-items).

Export

POST /models/{modelId}/queries/{queryId}/export/{format} This operation exports the result of the query with indicated modelId and queryId to the specified format (e.g. "csv" or "excel-html").

The content of the request is a JSON object which contains the query definition:

{
  "query": {
	    "id": "MyQueryID",
			.   .   .   .  .
	}
}

The response is a stream of the data in a specified format or a JSON object with the error message.