If you have a lot of Redis databases or you are using RedisInsight as part of some automated workflow, you might want to add databases programmatically.

Now this is possible using our experimental REST API. Below is the documentation for the endpoints required to add databases.

Note that this API should not be considered stable at this point and might change or break entirely in future releases. Do not rely on this API for production.

Add Redis database

Used to add Redis databases to RedisInsight.

URL : /api/instance/

Method : POST

Body Type: JSON

Auth required : NO

Parameters

These are the required parameters for any type of database.

ParameterTypeDescription
namestringA nick name for the Redis database. Any string is valid
connectionTypestringOne of "STANDALONE", "CLUSTER" or "SENTINEL". For any Redis Enterprise database (even with database clustering enabled), use "STANDALONE"

The remaining parameters depend on the connection type.

Standalone database parameters

Standalone databases are added using connectionType: "STANDALONE".

The following additional parameters are required for standalone databases.

ParameterTypeDescription
hoststringThe hostname or IP address of your Redis database
portnumberThe port your Redis datanase is listening on. It should be an integer
passwordstring(optional) The password for your Redis database.
tlsobject(optional) TLS parameters for the database

Example

{
    "name": "QA Redis DB",
    "connectionType": "STANDALONE",
    "host": "redis.acme.com",
    "port": 6379
}
Redis cluster database parameters

Redis Cluster databases are added using connectionType: "CLUSTER".

The following additional parameters are required for Redis Cluster databases.

ParameterTypeDescription
seedNodesarrayAn array of objects describing the nodes of the cluster. At least one node should be specified. The objects must contain properties host (string) and port (integer)
usernamestring(optional) The username for your Redis database.
passwordstring(optional) The password for your Redis database.
tlsobject(optional) TLS parameters for the database

Example

{
    "name": "QA Redis Cluster DB",
    "connectionType": "CLUSTER",
    "username": "USERNAME",
    "password": "PASSWORD",
    "seedNodes": [
        {
            "host": "redis-cluster-node-1.acme.com",
            "port": 6379
        }
    ]
}
Sentinel-monitored database parameters

Sentinel-monitored databases are added using connectionType: "SENTINEL".

The following additional parameters are required for standalone databases.

ParameterTypeDescription
sentinelHoststringThe hostname or IP address of one of the sentinel instances
sentinelPortnumberThe hostname or IP address of one of the sentinel instances
sentinelPasswordstring(optional) The password for the sentinel instances
sentinelMasterobjectInformation about the monitored database that is to be added.
sentinelMaster.serviceNamestringThe name of the database to be added. This is the same name used in the sentinel monitor directive.
sentinelMaster.authPassstring(optional) The password, if any, for the monitored database. This can be different from the password of the sentinel instance itself. This is the same password as provided in the sentinel auth-pass directive.
tlsobject(optional) TLS parameters for the database

Example

{
    "name": "QA Redis Sentinel DB",
    "connectionType": "SENTINEL",
    "sentinelHost": "redis-sentinel.acme.com",
    "sentinelPort": 26379,
    "sentinelPassword": "sentinel-pass",
    "sentinelMaster": {
        "serviceName": "mymaster",
        "authPass": "opensesame",
    }
}

TLS parameters

TLS parameters can be used to specify how RedisInsight should connect to the Redis database over TLS.

The following parameters can be used:

ParameterTypeDescription
useTlsbooleanWhether to use TLS to connect to the database or not
clientAuthbooleanWhether TLS client authentication is required by the database
clientCertificateKeyPairobject(optional) The details of the client certificate and private key used to connect to the Redis database. If client authentication is not required, this has to be provided
verifyServerCertboolean(optional) Whether to verify server certificate
caCertobject(optional) The details of the CA certificate used to connect to the Redis database
TLS client certificate and key

The client certificate and key details can be provided in two forms:

  1. If the certificate and key has already been used for a database before, or has been added separately, the ID of that certificate can be provided directly.

    ParameterTypeDescription
    idnumberThe ID of the client certificate/key pair
  2. Alternatively, to create a new client certificate/key pair for the database, a name must be provided along with the certificate and key strings.

    ParameterTypeDescription
    newobjectThe details of the new client certificate/key pair to be created
    new.namestringThe name of the new client cert/key pair
    new.certstringThe client certificate string
    new.keystringThe client private key string

Example

  1. Using an existing client certificate/key pair for a new database.

    {
        "name": "Prod Redis Enterprise DB",
        "connectionType": "STANDALONE",
        "host": "redis-ent.acme.com",
        "port": 6379,
        "tls": {
            "useTls": true,
            "clientAuth": true,
            "clientCertificateKeyPair": {
                "id": 6
            }
        }
    }
    
  2. Creating a new client certificate/key pair while adding the database.

    {
        "name": "Prod Redis Enterprise DB",
        "connectionType": "STANDALONE",
        "host": "redis-ent.acme.com",
        "port": 6379,
        "tls": {
            "useTls": true,
            "clientAuth": true,
            "clientCertificateKeyPair": {
                "new": {
                    "name": "Prod client certificate",
                    "cert": "-----BEGIN CERTIFICATE-----...-----END CERTIFICATE-----",
                    "key": "-----BEGIN PRIVATE KEY-----...-----END PRIVATE KEY-----"
                }
            }
        }
    }
    
TLS CA certificate

The CA certificate details can be provided in two forms:

  1. If the certificate has already been used for a database before, the name of that certificate can be provided directly.

    ParameterTypeDescription
    namestringThe name of the CA certificate
  2. Alternatively, to create a new CA certificate for the database, a name must be provided along with the certificate string.

    ParameterTypeDescription
    newobjectThe details of the new CA certificate to be created
    new.namestringThe name of the new CA cert
    new.certstringThe CA certificate string

Example

  1. Using an existing CA certificate for a new database.

    {
        "name": "Prod Redis Enterprise DB",
        "connectionType": "STANDALONE",
        "host": "redis-ent.acme.com",
        "port": 6379,
        "tls": {
            "useTls": true,
            "caCert": {
                "name": "my-cert"
            }
        }
    }
    
  2. Creating a new CA certificate while adding the database.

    {
        "name": "Prod Redis Enterprise DB",
        "connectionType": "STANDALONE",
        "host": "redis-ent.acme.com",
        "port": 6379,
        "tls": {
            "useTls": true,
            "caCert": {
                "new": {
                    "name": "Prod CA certificate",
                    "cert": "-----BEGIN CERTIFICATE-----...-----END CERTIFICATE-----",
                }
            }
        }
    }
    

Success response

Code : 201 Created

Add TLS certificate and key pair

Used to add a new TLS certificate and private key pair to use to connect to a Redis database.

URL : /api/tls-client-cert/

Method : POST

Body Type: JSON

Auth required : NO

Parameters

ParameterTypeDescription
namestringThe name of the new cert/key pair
certstringThe certificate string
keystringThe private key string

Success response

The name and ID is returned in the response body. The ID can be used to reference this certificate/key pair when adding databases.

Code : 201 Created

Body :

{
    "certificate": {
        "id": 1,
        "name": "VeriCert ACME Certificate"
    }
}

Get added TLS certificate and key pairs

Used to retrieve a list of previously added TLS certificate and private key pair to use to connect to a Redis database.

URL : /api/tls-client-cert/

Method : GET

Auth required : NO

Success response

A list of objects, each containing the client certificate’s name and ID, is returned in the response body. The ID can be used to reference this certificate/key pair when adding databases.

Code : 200 OK

Body :

{
    "certificates": [
        {
            "id": 6,
            "name": "VeriCert ACME Certificate"
        }
    ]
}