Skip to content

REST API Index

REST Endpoint

The default HTTP API endpoint is http://0.0.0.0:8088/.

Change the server configuration that controls the HTTP API endpoint by setting the listeners parameter in the ksqlDB server config file. For more info, see listeners. To configure the endpoint to use HTTPS, see Configure ksqlDB for HTTPS.

Content Types

The ksqlDB HTTP API uses content types for requests and responses to indicate the serialization format of the data and the API version.

Your request should specify this serialization format and version in the Accept header, for example:

1
Accept: application/vnd.ksql.v1+json

The less specific application/json content type is also permitted. However, this is only for compatibility and ease of use, and you should use the versioned value where possible. application/json maps to the latest versioned content type, meaning the response may change after upgrading the server to a later version.

The server also supports content negotiation, so you may include multiple, weighted preferences:

1
Accept: application/vnd.ksql.v1+json; q=0.9, application/json; q=0.5

For example, content negotiation is useful when a new version of the API is preferred, but you are not sure if it is available yet.

Here's an example request that returns the results from the LIST STREAMS command:

1
2
3
4
5
6
curl -X "POST" "http://localhost:8088/ksql" \
     -H "Accept: application/vnd.ksql.v1+json" \
     -d $'{
  "ksql": "LIST STREAMS;",
  "streamsProperties": {}
}'

Here's an example request that retrieves streaming data from TEST_STREAM:

1
2
3
4
5
6
curl -X "POST" "http://localhost:8088/query" \
     -H "Accept: application/vnd.ksql.v1+json" \
     -d $'{
  "sql": "SELECT * FROM TEST_STREAM EMIT CHANGES;",
  "streamsProperties": {}
}'

Provide the --basic and --user options if basic HTTPS authentication is enabled on the cluster, as shown in the following command.

1
2
3
4
5
6
7
curl -X "POST" "https://localhost:8088/ksql" \
     -H "Accept: application/vnd.ksql.v1+json" \
     --basic --user "<API key>:<secret>" \
     -d $'{
  "ksql": "LIST STREAMS;",
  "streamsProperties": {}
}'

Errors

All API endpoints use a standard error message format for any requests that return an HTTP status indicating an error (any 4xx or 5xx statuses):

1
2
3
4
5
6
7
HTTP/1.1 <Error Status>
Content-Type: application/json

{
    "error_code": <Error code>
    "message": <Error Message>
}

Some endpoints may include additional fields that provide more context for handling the error.


Last update: 2021-07-16