Commands to interact with ksqlDB using the REST API
This package provides a small set of aux4 commands for managing ksqlDB and Kafka objects via the ksqlDB REST API. Use it to query server info and health, list and manage topics, streams, and tables, and to run ad-hoc ksql statements and pull/push queries. It’s designed to be a lightweight CLI wrapper around curl + jq so you can script common ksqlDB tasks from the terminal and in CI.
aux4 aux4 pkger install community/ksqldb
This package requires system dependencies. You need to have one of the following system installers:
For more details, see system-installer.
Run a quick check against a local ksqlDB server (defaults to http://localhost:8088):
aux4 ksqldb info
This queries the server info endpoint and prints the raw JSON response from ksqlDB. In tests the server status is read like this:
aux4 ksqldb info | jq -r '.KsqlServerInfo.serverStatus'
which returns RUNNING for a healthy server.
Get server basic information and health status. Both commands accept the optional variables server, username and password (server defaults to http://localhost:8088).
Example:
aux4 ksqldb info | jq -r '.KsqlServerInfo.serverStatus'
This prints the ksqlDB server status (for example: RUNNING).
Example:
aux4 ksqldb health | jq -r '.isHealthy'
This returns true when the server reports healthy.
List Kafka topics visible to ksqlDB.
Example (from tests):
aux4 ksqldb topic list | jq -r '.[].name' | grep test-aux4-topic
This looks for the test topic name test-aux4-topic in the listed topics.
Manage and inspect ksqlDB streams.
Examples (extracted from tests):
List and find a test stream:
aux4 ksqldb stream list | jq -r '.[].name' | grep TEST_AUX4_STREAM
Describe a specific stream:
aux4 ksqldb stream describe TEST_AUX4_STREAM | jq -r '.[0].sourceDescription.name'
Drop a stream that was created for tests:
aux4 ksqldb stream drop TEST_AUX4_STREAM_DROP | jq -r '.[0].commandStatus.status'
The last command returns SUCCESS when the drop completed.
List, describe and drop materialized tables.
Examples (from tests):
List and match a test table:
aux4 ksqldb table list | jq -r '.[].name' | grep TEST_AUX4_TABLE
Describe the table:
aux4 ksqldb table describe TEST_AUX4_TABLE | jq -r '.[0].sourceDescription.name'
Drop a test table and check status:
aux4 ksqldb table drop TEST_AUX4_TABLE_DROP | jq -r '.[0].commandStatus.status'
Run ksql statements, pull queries, push queries, and manage running queries.
The query run, query select, and query push commands support parameter binding for safe value substitution. Use :paramName placeholders in your ksql statement and pass values via --paramName:
# Insert with parameter binding
aux4 ksqldb query run "INSERT INTO my_stream (id, name) VALUES (1, :name)" --name "John"
# Select with parameter binding
aux4 ksqldb query select "SELECT * FROM my_table WHERE name = :name" --name "John"
# Push query with parameter binding
aux4 ksqldb query push "SELECT * FROM my_stream WHERE status = :status EMIT CHANGES" --status "active"
Note: Parameters are bound as strings (quoted values) for SQL injection protection. This works well for string columns. For integer columns in WHERE clauses, you may need to use literal values or cast appropriately.
List queries (returns an array):
aux4 ksqldb query list | jq -r 'type'
Run statements to show topics/streams/tables (returns typed JSON array entries). For example:
aux4 ksqldb query run "show topics" | jq -r '.[0]["@type"]'
which prints kafka_topics.
Create a stream/table and perform insert + select (tests perform setup/teardown around these commands). To insert a row and then query the materialized table (the test waits briefly to allow the table to be populated):
aux4 ksqldb query run "INSERT INTO TEST_AUX4_QUERY_STREAM (id, name) VALUES (1, 'test')" > /dev/null && sleep 8 && aux4 ksqldb query select "SELECT * FROM TEST_AUX4_QUERY_TABLE WHERE id = 1" | head -1 | jq -r '.columnNames[0]'
This sequence inserts a row into the stream, waits for the table to be populated, and then prints the first column name (test expectation: ID).
Insert and select using parameter binding:
# Insert with params
aux4 ksqldb query run "INSERT INTO my_stream (id, name) VALUES (1, :name)" --name "alice"
# Select with params
aux4 ksqldb query select "SELECT * FROM my_table WHERE name = :name" --name "alice"
This example reads the server info and prints the serverStatus field:
aux4 ksqldb info | jq -r '.KsqlServerInfo.serverStatus'
In tests this returns:
RUNNING
This example lists topics and filters for the test topic created by the test suite:
aux4 ksqldb topic list | jq -r '.[].name' | grep test-aux4-topic
Expected line in tests:
test-aux4-topic
The test suite creates streams via query.run, then uses the stream list and describe commands:
aux4 ksqldb stream list | jq -r '.[].name' | grep TEST_AUX4_STREAM
and
aux4 ksqldb stream describe TEST_AUX4_STREAM | jq -r '.[0].sourceDescription.name'
Both return the stream name when successful.
A test inserts into a stream and then executes a pull query against the derived table to verify the data:
aux4 ksqldb query run "INSERT INTO TEST_AUX4_QUERY_STREAM (id, name) VALUES (1, 'test')" > /dev/null && sleep 8 && aux4 ksqldb query select "SELECT * FROM TEST_AUX4_QUERY_TABLE WHERE id = 1" | head -1 | jq -r '.columnNames[0]'
This prints the column name (expected in tests: ID) once the row is materialized.
This package does not specify a license. See LICENSE for details.