Kafka-python retrieves a list of topics

I am using kafka-python and I am wondering if there is a way to show all topics.

Something like that:

./bin/kafka-topics.sh --list --zookeeper localhost:2181
+6
source share
3 answers
import kafka
consumer = kafka.KafkaConsumer(group_id='test', bootstrap_servers=['server'])
consumer.topics()
+16
source

Try the KafkaConsumer.topics () method .

+1
source

Using confluent kafa and getting topics by group ID:

con = Consumer({'bootstrap.servers': 'host1:port,host2:port','group.id':'some-group-id'})
topic_meta = con.list_topics()
topic_meta.topics.keys()
0
source

All Articles