Starting the REST API

This topic provides a brief tutorial to help you get started with the HCL OneDB™ REST API.

To start the HCL OneDB REST API:
  1. Create a REST configuration file. You can refer to the example properties file in the HCL OneDB APIs package.

    The REST configuration file must contain a onedb.servers property which defines one or more HCL OneDB for the REST API to connect to. All other configuration properties are optional.

    Sample configuration file

    # REST port number
    port: 8080
    
    # List of database servers that the REST API can connect to 
    onedb.servers:
      - 
        alias: server1
        host: host1.mycompany.com
        port: 9088
      -
        alias: server2
        host: host2.mycompany.com
        port: 9088
                  
    # Optional, but recommended, properties to enable HTTPS
    tls.enable: true
    tls.keystore.type: pkcs12
    tls.keystore.file: rest-keystore.pkcs12
    tls.keystore.password: myPassword
    
    # Optional, but recommended, property to enable anti-CSRF tokens
    security.csrf.token.enable: true
    Important: The onedb.servers property is required. This specifies the alias, host, and port number for the databases servers that HTTP clients will be able to access through the REST API.
    Important: In addition to onedb.servers, it is recommended that you configure the TLS (HTTPS) and anti-CSRF configuration properties in order to secure your REST API when running it in a production environment. See the Securing the REST API topic for more information on how to properly secure your REST API server.
  2. Start the REST server using the following Java™ command:
    java -jar onedb-rest.jar -config rest-config.yaml
    where rest-config.yaml is the name of your REST configuration file.
    Important: The REST server requires Java 11 or higher.
  3. By default, the REST server will write its logging information to a file named onedb-rest.log.