DataCaster REST API Support
A simple HTTP based approach called REST, or REpresentational State Transfer, is being used on the web to connect applications. A number of service APIs on the web today support or use REST and provide remote applications an easy way to access data and invoke actions on remote servers. This can certainly be user to query and execute statements from remote databases.
DataCaster provides a way to query databases over the web using REST. The REST query capability allows a remote application to perform any SQL query over the network and return the results in SQL. This will be extended to provide a full range of functionality over the REST API.
Using the REST API
The REST API is provided as a Tomcat application with complete source code that can be modified and extended as needed for your installation. To activate the REST API, install the dcasterapi.war file in the Tomcat webapps directory.
Some help information is provided at the /dcasterapi/ page on usage of the REST API.
Default Query URL
The default URL to execute the query is: /dcasterapi/rest/query
Query Parameters
Here is the information about the parameters:
A example usage of query:
http://serverip:port/dcasterapi/rest/query?db=testdb&q=select+*+from+table1
If required parameters are not sent, e.g. database name, then HTTP Status-Code 406: Not Acceptable is returned.
Authentication.
Basic Type of Authentication is currently supported.
If Request Header does not contain the Authentication information, HTTP Status-Code 401: Unauthorized. is sent.
If Authentication fails, HTTP Status-Code 400: Bad Request, is sent.
Errors and Warnings
If the query execution fails, then HTTP Status-Code 412: Precondition Failed is sent with input data and exception message.
Limitations:
Only first 1000 rows of the result table is sent to the client, with a warning message.
Sample Python script
A python script named dcasterapi.py has been provided to demonstrate the usage of DataCaster REST API. This script is available in the DataCasterRestApi sources.