Using SQL Stream Builder REST API

You can use the REST API to monitor, manage and configure the SQL Stream jobs with GET, POST and DELETE HTTP methods. You can use the SQL Stream Builder (SSB) REST API in the command line, import them to REST API Tools or by accessing the Swagger UI.

The following HTTP methods are available for SSB:
  • GET to query information about the specified endpoint
  • POST to create resources for the specified endpoint
  • PUT to update existing resources for the specified endpoint as a whole
  • PATCH to partially update existing resources for the specified endpoint
  • DELETE to remove objects from the specified endpoint
The REST API Reference document contains the available endpoints for SQL Stream Builder. However, you can also reach the SSB REST API reference document from on the main menu of Streaming SQL Console.

You can use the SSB REST API with Command Line Interface (CLI), you can also import the REST API swagger.json file to a REST API Tool, for example Postman, and you also have the option to use the REST API with the Swagger User Interface (UI).

The Streaming SQL Engine API details the following operations for SQL Stream Builder and Flink:
  • Heartbeat
  • Admin Operations
  • User Operations
  • User Keytab Operations
  • Data Source Operations
  • Table Operations
  • Project Operations
  • Project Environment Operations
  • Project Sync Operations
  • Project Invitation Operations
  • Project Permission Operations
  • SQL Operations
  • SSB Session Operations
  • Job Operations
  • Sampling Operations
  • Flink Job Operations
  • Flink Session Cluster Operations
  • Artifact Operations
  • UDF Artifact Operations
  • UDF Operations
  • API Key Operations
  • Connector Operations
  • Data Format Operations
  • Diagnostic Operations
The SSB project-related endpoints can be used with specifying which project the request is submitted to by adding the project ID parameter to the endpoint. This means that even though a project is selected as the active project on Streaming SQL Console, you can submit any request to a different project to which you have access to. The REST API user permissions are the same for a project as it is configured on the Members page in a project. The requests that are submitted using a specific project ID are submitted as a new session that does not interfere with the already existing user sessions in SSB.

Accessing the project ID

You can find the project ID on the homepage of Streaming SQL Console:
You can also use the GET /api/v2/projects call in CLI to list all projects that the user has access to.

Using REST API Tool

When using REST API Tools, you need to connect to the cluster that hosts the SQL Stream Builder REST API. You can also use the following URL in a browser to download the swagger.json file when you need to manually upload the REST API endpoints for a Tool.
http(s)://[***CLUSTER_DOMAIN***]:[***STREAMING_SQL_ENGINE_SERVER_PORT***]/swagger/api-docs/public

Using REST API with CLI

When using the SSB REST API with CLI Tool, you need to create the POST or GET commands with curl, and also include the Streaming SQL Engine hostname, port and the required operation for the endpoint. The submitted commands return the information, or complete the process you have requested and display the status in the CLI.

The following examples show a secured and unsecured GET method to list the SQL jobs:

$ curl -H 'Username: [***YOUR_USERNAME***]' \
       'https://[***CLUSTER_DOMAIN***]:[***STREAMING_SQL_ENGINE_SERVER_PORT***]/api/v1/ssb/jobs'
$ kinit [***YOUR_USERNAME***]
$ curl -ik --negotiate -u: \
       'https://[***CLUSTER_DOMAIN***]:[***STREAMING_SQL_ENGINE_SERVER_PORT***]/api/v1/ssb/jobs'
$ curl -ik --negotiate -u [***KNOX_USERNAME***[:[***KNOX_PASSWORD***] \
       'https://[***CLUSTER_DOMAIN***]:[***STREAMING_SQL_ENGINE_SERVER_PORT***]/gateway/cdp-proxy-api/ssb-sse-api/api/v1/ssb/jobs'

Using Swagger UI

You can access the Swagger UI to use the SSB REST API by adding your hostname and the Streaming SQL Engine port to the Swagger UI URL.

http(s)://[***CLUSTER_DOMAIN***]:[***STREAMING_SQL_ENGINE_SERVER_PORT***]/swagger-ui/index.html?configUrl=/swagger/api-docs/swagger-config

You can also download the swagger.json for the SSB REST API using the Swagger UI.