Skip to main content
Skip table of contents

Execute SQL statements

This API allows to execute SQL statements through HTTP requests. It requires an authorisation token (see Authentication ) and a connectionID (see Cluster connections ) in the request headers.

Execute one or multiple queries synchronously

POST /api/query

Execute SQL statements through a connection. Statements must be contained in a JSON object where the value of the key is "query".

Example:

CODE
curl http://myindeximacluster:8082/api/query \
  -H "Authorization: $ACCESS_TOKEN" \
  -H "ConnectionId: $CONNECTION_ID" \
  -d "{query: 'SELECT * FROM tmp_sfa.tb1 LIMIT 5;SELECT 1;'}" \
  --compressed -s | jq

{"outputs":[{"columns":["key1","key2"],"results":[[2,"k2"],[1,"k1"]],"realSize":2,"outputs":[]},{"columns":["col0"],"results":[[1]],"realSize":1,"outputs":[]}]}

Execute one or multiple queries asynchronously

POST /api/query/async

Execute SQL statements through a connection. Instead of waiting for the result, this route returns a poolId of queries. The queries then run in the background. Statements must be contained in a JSON object where the value of the key is "query". Multiple queries are separated by a semi-colon.
The JSON return object contains the poolId and each query id.

Example:

CODE
curl http://myindeximacluster:8082/api/query/async \
  -H "Authorization: $ACCESS_TOKEN" \
  -H "ConnectionId: $CONNECTION_ID" \
  -d "{query: 'SELECT * FROM tmp_sfa.tb1 LIMIT 5;SELECT 1;'}" \
  --compressed -s | jq
  
  {
  "poolId": "98a13dcf-b640-423d-859e-d7b340caf125",
  "queries": [
    {
      "id": "fbb63c89-416f-4f64-bdce-b03375bc5af9",
      "query": "SELECT * FROM tmp_sfa.tb1 LIMIT 5"
    },
    {
      "id": "4f8b6d15-f018-414f-a4dd-cbb3b1efd2ac",
      "query": "SELECT 1"
    }
  ]
}
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.