Kafka-python retrieve the list of topics

teoreda picture teoreda · Apr 15, 2016 · Viewed 11.4k times · Source

I'm using kafka-python and I'm wondering if there is a way for showing all the topics.

Something like this:

./bin/kafka-topics.sh --list --zookeeper localhost:2181

Answer

secfree picture secfree · Jul 27, 2017
import kafka
consumer = kafka.KafkaConsumer(group_id='test', bootstrap_servers=['server'])
consumer.topics()