MCPcopy Index your code
hub / github.com/confluentinc/confluent-kafka-python

github.com/confluentinc/confluent-kafka-python @legacy-v3.0.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release legacy-v3.0.1 ↗ · + Follow
120 symbols 274 edges 20 files 48 documented · 40% updated 1d agov2.15.0 · 2026-06-30★ 493130 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Confluent's Apache Kafka client for Python

Confluent's Kafka client for Python wraps the librdkafka C library, providing full Kafka protocol support with great performance and reliability.

The Python bindings provides a high-level Producer and Consumer with support for the balanced consumer groups of Apache Kafka 0.9.

See the API documentation for more info.

License: Apache License v2.0

Usage

Producer:

from confluent_kafka import Producer

p = Producer({'bootstrap.servers': 'mybroker,mybroker2'})
for data in some_data_source:
    p.produce('mytopic', data.encode('utf-8'))
p.flush()

High-level Consumer:

from confluent_kafka import Consumer

c = Consumer({'bootstrap.servers': 'mybroker', 'group.id': 'mygroup',
              'default.topic.config': {'auto.offset.reset': 'smallest'}})
c.subscribe(['mytopic'])
while running:
    msg = c.poll()
    if not msg.error():
        print('Received message: %s' % msg.value().decode('utf-8'))
c.close()

See examples for more examples.

Prerequisites

Install

Install from PyPi:

$ pip install confluent-kafka

Install from source / tarball:

$ pip install .

Build

$ python setup.by build

If librdkafka is installed in a non-standard location provide the include and library directories with:

$ CPLUS_INCLUDE_PATH=/path/to/include LIBRARY_PATH=/path/to/lib python setup.py ...

Tests

Run unit-tests:

$ py.test

NOTE: Requires py.test, install by pip install pytest

Run integration tests:

$ examples/integration_test.py <kafka-broker>

WARNING: These tests require an active Kafka cluster and will make use of a topic named 'test'.

Generate documentation

Install sphinx and sphinx_rtd_theme packages and then:

$ make docs

or:

$ python setup.by build_sphinx

Documentation will be generated in docs/_build/.

Core symbols most depended-on inside this repo

dbg
called by 16
confluent_kafka/kafkatest/verifiable_client.py
send
called by 7
confluent_kafka/kafkatest/verifiable_client.py
send_records_consumed
called by 6
confluent_kafka/kafkatest/verifiable_consumer.py
c_parts_to_py
called by 4
confluent_kafka/src/confluent_kafka.c
py_to_c_parts
called by 4
confluent_kafka/src/confluent_kafka.c
do_commit
called by 4
confluent_kafka/kafkatest/verifiable_consumer.py
KafkaError_new_or_None
called by 3
confluent_kafka/src/confluent_kafka.c
err
called by 3
confluent_kafka/kafkatest/verifiable_client.py

Shape

Function 89
Method 23
Class 8

Languages

C60%
Python40%

Modules by API surface

confluent_kafka/src/confluent_kafka.c43 symbols
confluent_kafka/src/Consumer.c15 symbols
confluent_kafka/src/Producer.c14 symbols
confluent_kafka/kafkatest/verifiable_consumer.py13 symbols
examples/integration_test.py11 symbols
confluent_kafka/kafkatest/verifiable_client.py8 symbols
tests/test_TopicPartition.py3 symbols
tests/test_Consumer.py3 symbols
confluent_kafka/kafkatest/verifiable_producer.py3 symbols
tests/test_Producer.py2 symbols
tests/test_misc.py1 symbols
tests/test_enums.py1 symbols

For agents

$ claude mcp add confluent-kafka-python \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page