Skip to main content
Skip table of contents

API Dev Console

Connections API

A connection is a link to an Indexima cluster.
Connections API makes it possible to create Connections and execute SQL statements through HTTP requests.

Node: This API is available on your Developer Console server, the prefix url is /api/v1

HTTP Routes

Retrieve all connections

GET /v1/connections

Create a new connection

POST /v1/connections

The request body should contain the connection object in JSON that you want to create.

Input example with a Basic Authentication:

json body

JS
{
  name: "MyFirstConnection",
  url: "indexima.my-server.io:10000/default",
  username: "my_user",
  password: "********",
  impersonate: false
}

When the status code is 200, JS will return a generated id.

Retrieve a connection

GET /v1/connections/:id

 Return a connection for a given id.

Delete a connection

DELETE /v1/connections/:id

Delete a connection for a given id.

Connection properties

NameTypeDescription
idStringGenerated unique ID (assigned on creation).
creatorStringUsername of creator (assigned on creation).
nameStringDisplay the name of the connection.
urlStringJDBC URL to the target cluster.
usernameStringUsername for basic authentication or impersonation.
passwordStringPassword for basic authentication.
impersonateBooleanIf true, enable impersonation.

Execute SQL statements

Execute a single query

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".

Authorization and Connection Id must be contained in headers.

Input example:

json body

JS
{
  query: "SELECT * FROM countries_table LIMIT 5"
}

The JSON return object contains all the statement's results.

Output example:

json return body

JS
{"outputs":[{"columns":["country","population"],"results":[["France",66000000],["Spain",46000000],["Italy",60000000],["Germany",83000000],["Switzerland",8500000]],"outputs":[]}]}

Complete example with httpie

Execute query with httpie

BASH
URL=localhost:8082

# Login
TOKEN=$(http POST ${URL}/api/login name=admin password=password |jq -r .id)
echo ${TOKEN}

# Get Id of the first connection
CONNECTION_ID=$(http GET ${URL}/api/v1/connections \
  Authorization:${TOKEN} |jq -r '.[0]'.id)
echo $CONNECTION_ID

# Execute query
http POST ${URL}/api/query Authorization:${TOKEN} ConnectionId:${CONNECTION_ID} query="SELECT 1"

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.

Authorization and ConnectionId must be present in headers.

The JSON return object contains the poolId and each query id.

Input example

json body

JS
{
  query: "SELECT 1 ; SELECT 2"
}

Return example

json return body

JS
{
    "poolId": "36e127b5-ce41-431c-ad7a-dd60871da721",
    "queries": [
        {
            "id": "dc5d94c0-b719-46c6-9250-6527a8005312",
            "query": "SELECT 1"
        },
        {
            "id": "5136a022-5200-4e41-b485-55b77b7a6bc6",
            "query": "SELECT 2"
        }
    ]
}

Complete example with httpie and jq

Execute query with httpie

BASH
URL=localhost:8082

# Login
TOKEN=$(http POST ${URL}/api/login name=admin password=password |jq -r .id)
echo ${TOKEN}

# Get Id of the first connection
CONNECTION_ID=$(http GET ${URL}/api/v1/connections \
  Authorization:${TOKEN} |jq -r '.[0]'.id)
echo $CONNECTION_ID

# Execute query
http POST ${URL}/api/query/async Authorization:${TOKEN} ConnectionId:${CONNECTION_ID} query="SELECT 1 ; SELECT 2"
JavaScript errors detected

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

If this problem persists, please contact our support.