GridDB Web API Reference

Revision: 4.5.0-236

1 Web API

1.1 Overview

GridDB provides a Web API to register rows, acquire rows and execute a TQL and a SQL statement for GridDB cluster. The Web API is configured as a web application.

Web API
Web API

The functions of GridDB Web API are shown below.

1.2 Using Web API

To use gs_admin, Java has to be installed beforehand. The compatible versions are as follows.

The procedure to install and configure Web API is as follows.

  1. Installation of a library package.
  2. Installation of Web API package.
  3. Setting of the destination cluster
  4. Setting of the Web API operation (optional)
  5. Setting of the log output destination (optional)

1.2.1 Installation of a library package.

Install the following packages.

Log into a machine installed with the Web API as a root user, and install the package using the command below.

# rpm -Uvh griddb-ee-java_lib-X.X.X-linux.x86_64.rpm

*X.X.X indicates the GridDB version.

1.2.2 Installation of Web API package.

Install the Web API package (griddb-ee-webapi-XX.X-linux.x86_64.rpm).

Log into a machine installed with the Web API as a root user, and install the package using the command below.

# rpm -Uvh griddb-ee-webapi-X.X.X-linux.x86_64.rpm

*X.X.X indicates the GridDB version.

After installing, Web API .jar file and configuration files are installed as follows:

/usr/griddb-webapi/griddb-webapi.jar                     : Web API jar file

/var/lib/gridstore/webapi/conf/griddb_webapi.properties  : Configuration file
                              /repository.json           : Cluster information definition file
                         /log                            : Log output directory

1.2.3 Setting of the destination cluster

Specify the information of the cluster to be connected from the Web API in the cluster information definition file ( /var/lib/gridstore/webapi/conf/repository.json ).

Based on the value of the cluster definition file (gs_cluster.json) of the cluster to be connected, specify the cluster configuration method to "mode", and the address information corresponding to the method.

Parameter JSON Data type Description
clusters array An array of the cluster information
name string cluster name
mode string Connection method (MULTICAST/FIXED_LIST/PROVIDER )
(mode=MULTICAST)
address string Multicast address for row registration and acquisition
port int Multicast port for row registration and acquisition
jdbcAddress string Multicast address for SQL SELECT execution
jdbcPort int Multicast port for SQL SELECT execution
(mode=FIXED_LIST)
transactionMember string Connection destination list for row registration and acquisition
sqlMember string Connection destination list for SQL SELECT execution
(mode=PROVIDER)
providerUrl string Provider URL for all functions

Example: In case of the multicast method

[Memo]

1.2.4 Setting of the Web API operation (optional)

Configure Web API behaviors by setting the configuration file (/var/lib/gridstore/webapi/conf/griddb_webapi.properties).

If not setting it will work with the default values. Configure the values according to the system.

1.2.4.1 GridDB configuration

Field Description Default value
failoverTimeout Specify the failover time (seconds) to repeat retries after detecting a node failure in Web API access to GridDB. 5
transactionTimeout The timeout time (second) of transaction. 30
containerCacheSize The maximum number of the container information on the container cache. 100

1.2.4.2 Web API configuration

Field Description Default value
port Web API service port (integer from 1 to 65535) 8081
maxGetRowSize The upper limit of the size for row acquisition , TQL execution, and SQL SELECT execution (MB) (integer from 1 to 2048) 20
maxPutRowSize The upper limit of the size for row registration.(MB) (1-2048) 20
loginTimeout The connection timeout time (second) for SQL SELECT execution
(An integer value can be specified. When it is less than 0, SQL SELECT statement can not be executed.)
5
maxQueryNum Maximum number of queries that can be included in one request (integer from 0 to 100) 10
maxLimit Maximum number of rows that can be acquired at one time when executing SQL or SQL (integer of 1 or more) 10000
timeZone Specify the time (in ±hh:mm or ±hhmm), time zone ID (only supports "Z"), or AUTO (takes over the JavaVM environment) as a time zone to be used in the offset calculation to retrieve time information in SQL and TQL. Z
authenticationMethod Specify either INTERNAL (internal authentication) or LDAP (LDAP authentication) as an authentication method to be used. dependent on the GridDB cluster settings
notificationInterfaceAddress To configure the cluster network in multicast mode when multiple network interfaces are available, specify the IP address of the interface to receive the multicast packets from. OS-dependent
sslMode For SSL connection settings, specify either DISABLED (SSL invalid) or PREFERRED (SSL valid, but non-SSL connection is allowed as well). PREFERRED

[Memo]

1.2.5 Setting of the log output destination (optional)

The Web API logs are output to the following directory by default.

/var/lib/gridstore/webapi/log

To change the output directory, edit the following file:

/var/lib/gridstore/webapi/conf/logback.xml

1.2.6 Starting and Stopping

Web API applications can be started and stopped using the service command.

# service griddb-webapi [start|stop|status|restart]

1.3 Common functions (HTTP request/response)

This chapter describes the HTTP request /response part common to each function.

1.3.1 URI

The URI to be accessed when using the Web API.

http://(Web API server IP) :(port)/griddb/v2/(command path)

[Memo]

1.3.2 Request header

Specify the following headers to the request header. (Common to all APIs)

Field Description Required
Content-Type "application/json; charset=UTF-8"
Authorization Specify the user and password to access the GridDB in the user: password format (Basic authentication)

1.3.3 Request body

Specify the request body as JSON format. Please refer to the JSON format of each functions.

[Memo]

1.3.4 Response code

Refer to the paragraph of each function for the response code.

1.3.5 Response body

Refer to the section on each function for the response body when the processing succeeds.

If processing fails, an error message is returned in the following format.

1.4 Row acquisition

This function acquire the rows from the container (table). It is also possible to narrow down the rows to be acquired by specifying conditions.

Path

/:cluster/dbs/:database/containers/:container/rows

Item Description
:cluster cluster name
:database Database name (specify "public" for a public database)
:container Container (table) name

HTTP method

POST

Request header

Refer to the request header.

Request body

Item Description JSON data type Required
/offset Acquisition start position An integer from 0 -
/limit The number of rows to be acquired An integer from 1
/condition Condition expression string -
/sort Sorting condition (column name asc or desc) string -

[Memo]

Example: Acquires row data with a column "id" value of 50 or more, sorts it in descending order by the value of "id", and acquires 100 values from the 11th

Response code

Code Description
200 Success
400 Incorrect request data
401 An authentication error, a connection error
404 Specified resource is not found
500 An error occurs in Web API or GridDB

Response body

Acquired rows will be returned as the following JSON data.

Item Description JSON data type
/columns An array of column information Array
/columns/name Column name string
/columns/type JSON Data type string
/columns/rows An array of the rows Array
/total Number of rows acquired when offset and limit are ignored Number
/offset Acquisition start position Number
/limit Number of acquisitions applied Number

Example:

Depending on the column data type, column values with the following JSON data type will be returned.

Classification JSON Data type JSON data type Example
Primitive Boolean type BOOL Boolean (true/false) true
String type STRING string "GridDB"
Integer type BYTE/SHORT/INTEGER/LONG Number 512
Floating point type FLOAT/DOUBLE Number 593.5
Date and time type TIMESTAMP Text string
・UTC
・format
YYYY-MM-DDThh:mm:ss.SSSZ
"2016-01-16T10:25:00.253Z"
Spatial-type GEOMETRY Text string (WKT representation) POLYGON((0 0,10 0,10 10,0 10,0 0))
Array Boolean type BOOL Array of boolean values [true, false, true]\
String type STRING Array of text string values ["A","B","C"]
Integer type BYTE/SHORT/INTEGER/LONG Array of numbers [100, 39, 535]
Floating point type FLOAT/DOUBLE Array of numbers [3.52, 6.94, 1.83]
Date and time type TIMESTAMP Array of text string values
(Format is same as the primitive one)
["2016-01-16T10:25:00.253Z", "2016-01-17T01:42:53.038Z"]

[Memo]

1.5 Row registration

This function registers the rows to the container.

Specify the rows to be registered in JSON format. Multiple rows can be registered in one container.

[Memo]

Path

/:cluster/dbs/:database/containers/:container/rows

Item Description
:cluster cluster name
:database Database name (specify "public" for a public database)
:container Container (table) name

HTTP method

PUT

Request header

Refer to the request header.

Request body

Specify the rows as following JSON format.

Item Description JSON data type Required
/(row) Row (an array of column values) Array

Example:

Depending on the column data type, describe a column value with the following JSON data type.

Classification JSON Data type JSON data type Example
Primitive Boolean type BOOL Boolean value ( true or false )
or character string ("true" or "false")
true
String type STRING string "GridDB"
Integer type BYTE/SHORT/INTEGER/LONG Number or text string 512
Floating point type FLOAT/DOUBLE Number or text string 593.5
Date and time type TIMESTAMP Text string
・UTC
・format
YYYY-MM-DDThh:mm:ss.SSSZ
"2016-01-16T10:25:00.253Z"
Spatial-type GEOMETRY Text string (WKT representation) POLYGON((0 0,10 0,10 10,0 10,0 0))
Array Boolean type BOOL Boolean array or string array [true, false, true]
String type STRING Array of text string values ["A","B","C"]
Integer type BYTE/SHORT/INTEGER/LONG Numeric array or string array [100, 39, 535]
Floating point type FLOAT/DOUBLE Numeric array or string array [3.52, 6.94, 1.83]
Date and time type TIMESTAMP Array of text string values
(Format is same as the primitive one)
["2016-01-16T10:25:00.253Z", "2016-01-17T01:42:53.038Z"]

[Memo]

Response code

Code Description
200 Success
400 Incorrect request data
401 An authentication error, a connection error
404 Specified resource is not found
500 An error occurs in Web API or GridDB

Response body

If the process is successful, nothing is returned.

Please refer to response body in case of failure.

1.6 Database connection confirmation

Check the connection to the specified database.

Path

/:cluster/dbs/:database/checkConnection

Item Description
:cluster cluster name
:database Database name (specify "public" for a public database)

HTTP method

GET

Request header

Refer to the request header.

Request parameter

Item Description JSON Data type Required
/timeout Timeout value only for this API (seconds) An integer from 0 -

Response code

Code Description
200 Success
400 Incorrect request data
401 An authentication error, a connection error
500 An error occurs in Web API or GridDB

Response body

If the process is successful, nothing is returned.

Please refer to response body in case of failure.

1.7 Container list acquisition

Get a list of containers and tables. It is also possible to narrow down the containers to be acquired by specifying conditions.

Path

/:cluster/dbs/:database/containers

Item Description
:cluster cluster name
:database Database name (specify "public" for a public database)

HTTP method

GET

Request header

Refer to the request header.

Request parameter

Item Description JSON data type Required
/type Type of containers to be acquired Text string(collection or timeseries) -
/limit The number of rows to be acquired An integer from 0
/offset Acquisition start position An integer from 0 -
/sort Sorting expression string -

[Memo]

Response code

Code Description
200 Success
400 Incorrect request data
401 An authentication error, a connection error
500 An error occurs in Web API or GridDB

Response body

Acquired rows will be returned as the following JSON data.

Item Description JSON data type
/names Array of container names Array
/total Number of acquisitions when offset and limit are ignored Number
/offset Acquisition start position Number
/limit Number of acquisitions applied Number

Example:

1.8 Container information acquisition

Get the information on a container or a table.

Path

/:cluster/dbs/:database/containers/:container/info

Item Description
:cluster cluster name
:database Database name (specify "public" for a public database)
:container Container (table) name

HTTP method

GET

Request header

Refer to the request header.

Request body

-

Response code

Code Description
200 Success
400 Incorrect request data
401 An authentication error, a connection error
404 Specified resource is not found
500 An error occurs in Web API or GridDB

Response body

Item Description JSON data type
/container_name An array of column information Array
/container_type Column name string
/rowkey Column name string
/columns Information of columns Array
/columns/name Column name string
/columns/type Data type of column string
/columns/index Index Array

Example:

[Memo]

1.9 TQL command execution

Execute a TQL statement. Multiple TQL statements can be sent at once. The value of specific columns can be set to acquire in the execution result.

Path

/:cluster/dbs/:database/tql

Item Description
:cluster cluster name
:database Database name (specify "public" for a public database)

HTTP method

POST

Request header

Refer to the request header.

Request body

Item Description JSON data type Required
/name Target container name string
/stmt TQL statement string
/columns Array of acquisition column names Array -

[Memo]

Example:

Response code

Code Description
200 Success
400 Incorrect request data
401 An authentication error, a connection error
404 Specified resource is not found
500 An error occurs in Web API or GridDB

Response body

Item Description JSON data type
/columns An array of column information Array
/columns/name Column name string
/columns/type JSON Data type string
/results TQL execution results Array
/total Number of acquisitions when offset and limit are ignored Number
/offset Acquisition start position Number
/limit Number of acquisitions applied Number

[Memo]

Example:

1.10 Row deletion

This function deletes the rows from the container (table).

Path

/:cluster/dbs/:database/containers/:container/rows

Item Description
:cluster cluster name
:database Database name (specify "public" for a public database)
:container Container (table) name

HTTP method

DELETE

Request header

Refer to the request header.

Request body

Item Description JSON data type Required
/(key) Row key Array -

Example:

Response code

Code Description
204 Success
400 Incorrect request data
401 An authentication error, a connection error
404 Specified resource is not found
500 An error occurs in Web API or GridDB

Response body

If the process is successful, nothing is returned.

Please refer to response body in case of failure.

[Memo]

1.11 Creating a container

Create a container.

Path

/:cluster/dbs/:database/containers

Item Description
:cluster cluster name
:database Database name (specify "public" for a public database)

HTTP method

POST

Request header

Refer to the request header.

Request body

Item Description JSON data type
/container_name An array of column information Array
/container_type Column name string
/rowkey Column name string
/columns Information of columns Array
/columns/name Column name string
/columns/type Data type of column string
/columns/index Index Array

Example:

Response code

Code Description
201 Success
400 Incorrect request data
401 An authentication error, a connection error
409 The specified container already exists.
500 An error occurs in Web API or GridDB

Response body

If the process is successful, nothing is returned.

Please refer to response body in case of failure.

[Memo]

1.12 Container deletion

Delete a container

Path

/:cluster/dbs/:database/containers

Item Description
:cluster cluster name
:database Database name (specify "public" for a public database)

HTTP method

DELETE

Request header

Refer to the request header.

Request body

Item Description JSON data type Required
/(name) <Container name> Array -

Example:

Response code

Code Description
204 Success
400 Incorrect request data
401 An authentication error, a connection error
500 An error occurs in Web API or GridDB

Response body

If the process is successful, nothing is returned.

Please refer to response body in case of failure.

1.13 SQL SELECT execution

This function executes a SQL SELECT statement in a GridDB database.

Path

/:cluster/dbs/:database/sql

Item Description
:cluster cluster name
:database Database name (specify "public" for a public database)

HTTP method

POST

Request header

Refer to the request header.

Request body

Specify a SQL SELECT statement as following JSON format.

Item Description JSON data type Required
/type Type of query statement (only "sql-select" can be specified) string
/stmt A SQL SELECT statement string

Example:

Response code

Code Description
200 Success
400 Incorrect request data
401 An authentication error, a connection error
404 Specified resource is not found
500 An error occurs in Web API or GridDB

Response body

Item Description JSON data type
/columns An array of column information Array
/columns/name Column name string
/columns/type JSON Data type string
/rows SQL SELECT execution results Array

Example:

Depending on the column data type, column values with the following JSON data type will be returned.

Classification JSON Data type JSON data type Example
Primitive Boolean type BOOL Boolean (true/false) true
String type STRING string "GridDB"
Integer type BYTE/SHORT/INTEGER/LONG Number 512
Floating point type FLOAT/DOUBLE Number 593.5
Date and time type TIMESTAMP Text string
・UTC
・format
YYYY-MM-DDThh:mm:ss.SSSZ
"2016-01-16T10:25:00.253Z"

[Memo]

1.14 Checking of operation

To check the operation of the Web API, use curl command in linux or another command.

1.15 Uninstallation

Delete the directory and the distributed files in the following procedures after stopping the Web API.

# rpm -e griddb-ee-webapi