Using Embedded web server (version 6.5 and after)
From version 6.5, MachBase supports convenient and fast Rest API functions through the web server built into the server.
Machbase Edition support embedded web server
All type of machbase editions are supported. (Edge / Fog / Cluster)
Location of version-specific .conf files
$EACH_BROKER_HOME/conf/machbase.conf (Modify by Broker) $EACH_BROKER_HOME/http/conf/http.conf (modify all per Broker)
Added properties for embedded web server
machbase.conf (set as PROPERTY = VALUE)
Whether to run the embedded web server 0: not driven, 1: driven
|HTTP_PORT_NO||Embedded web server connection port number Port range: 0 ~ 65535 Default : 5657|
|HTTP_MAX_MEM||Maximum memory used by one Web Session Min: 1048576 (1MB) Default : 536870912 (512MB|
|HTTP_AUTH||Whether to use Basic authentication when using the Embedded Web Server 0: Authentication not used, 1: Authentication enabled|
http.conf (set in JSON format)
html file location based on $MACHBASE_HOME
Default : http/html ($MACHBASE_HOME/http/html)
|max_request_size||Limit the maximum request byte size for one request|
|request_timeout_ms||Maximum response latency for one request (millisecond)|
|enable_auth_domain_check||Whether to enable domain authentication Set to "yes" or "no" value Default: "no"|
|reverse_proxy||change request url to specific url|
sample conf files
DDL / DML / AppendUsing REST API
In the case of Binary Append, if binary data is encoded in Base64 and transmitted, the server will decode it and store it. When outputting, binary data is returned after being encoded in Base64.
Input : Binary Data >> Base64 Encoding >> HTTP(POST) >> Base64 Decoding >> Append(BLOB Binary)
Output : BLOB Binary >> Base64 Encoding >> HTTP (GET) >> Base64 Decoding >> Save or View Binary
Binary Append Sample
Using HTTP Auth Property
This is an option to set authentication as a normal user by including the string 'Authorization: Basic Base64String' in the Request Header. Base64 string is written in ID@Host:Password structure. (However, the host name does not need to be correct. ID and password must be entered in Machbase user information.)
How to create a Basic Base64String for authorize
Using Auth Sample (HTTP_AUTH = 1)
Changing floating point precision with s option
Specify how many decimal places of response data to output Set to a value from 0 to 9 (If it is not a range value, it operates as 3)
Changing data Fetch mode (m option)
Decide whether to always display column names in response data (0: display, 1: do not display)
Default Fetch mode Sample (m=0)
Advanced Fetch mode Sample (m=1)
Handling of NULL values
When inserting or appending during DML processing, a NULL value can be entered as null as it is.
JSON Sample for appending null values
Sample result containing null values from SELECT
How To Use : Use MWA as a REST gateway(before 6.5 version)
$MACHBASE_HOME/webadmin/flask/MWAserver start is used to run Machbase Web Analytics (MWA), you can access the Machbase server using the Restful API.
The Machbase RESTful API can be used in conjunction with the MWA server configuration. When using the RESTful API, specify the server ID or Server name to use as the 's' parameter.
ex) The following example sends the query to the server whose ID is 3 (or server name is sample_server) among the servers set in MWA and receives the result
If it can not find the ID or name of the specified server, it returns the following json with a 404 error.
The default URL for the Restful API is:
http://hostname: port can be found by running the MWAserver start command to run MWA with the url to connect to the MWA.
Retrieves the data using the HTTP GET method. The return value is a json type. You can pass the query statement you want to execute using the 'q' parameter. The query below brings up a list of tables.
You can use the HTTP POST method to send the input value of the json type as a parameter. Below is an example of entering data into a test_table with three columns.
First, we execute a query that creates a table using the curl GET method.
Enter data using the POST method using the curl command. The data input json can use four keys, and the 'name' and 'values' keys must be entered.
Input table name
Input data to be input as a 2-dimensional array
Date format to be used
If data type is used
Server ID or name
Server defined in MWA
If you enter a date type, you must specify the date format. The date format must use the pattern used in Machbase. If not specified otherwise, YYYY-MM-DD is set to HH24: MI: SS mmm: uuu: nnn Machbase default format and the result value will not be returned properly if date format is not correct. When specifying date and time pattern, you should be careful of case sensitive.
Standard RESTful APIs should use the HTTP DELETE method, but Machbase methods use the HTTP GET Method to send a delete query. Below is an example of deleting data from test_table.
Creating, Altering, and Dropping Table
In Machbase, any query can be performed using the HTTP GET method. Therefore, the TABLE CREATE, ALTER, and DROP commands are also available.