In v5.5 of Confluent Platform the REST Proxy added new Admin API capabilities, including functionality to list, and create, topics on your cluster.
Check out the docs here and download Confluent Platform here. The REST proxy is Confluent Community Licenced.
To start with, you need the cluster ID:
➜ curl -s -X GET 'localhost:8082/v3/clusters'| jq '.data[0].attributes.cluster_id'
"rgfnzs2RS3O65A7VSpNatg"
You can get this along with the direct URL for the topics endpoint like this:
➜ curl -s -X GET 'localhost:8082/v3/clusters'| jq '.data[0].relationships.topics.links.related'
"http://localhost:8082/v3/clusters/rgfnzs2RS3O65A7VSpNatg/topics"
Using that topics endpoint URL you can list topics:
➜ curl -s -X GET 'http://localhost:8082/v3/clusters/rgfnzs2RS3O65A7VSpNatg/topics' |jq '.data[].attributes.topic_name'
"__confluent.support.metrics"
"_confluent-ksql-confluent_rmoff_01_command_topic"
"_kafka-connect-01-configs"
"_kafka-connect-01-offsets"
"_kafka-connect-01-status"
"_schemas"
"confluent_rmoff_01ksql_processing_log"
"ratings"
And you can create topics too:
➜ curl -s -X POST 'http://localhost:8082/v3/clusters/rgfnzs2RS3O65A7VSpNatg/topics' \
--header 'Content-Type: application/vnd.api+json' \
--data-raw '{
"data": {
"attributes": {
"topic_name": "rmoff_topic03",
"partitions_count": 12,
"replication_factor": 1
}
}
}'