Python kafka libraries

Updated Nov 2026

Python Kafka libraries connect applications to Apache Kafka to publish messages to topics and consume them from partitions. A client either implements the Kafka protocol in Python or wraps librdkafka, the C client library. These libraries let backend services and data pipelines stream events between systems.

Popularity

confluent-kafka has the most monthly downloads in this comparison, at 46.4M.

LibraryMonthly downloadsStarsLast releaseLicense
confluent-kafka
46.4M
528Nov 2026Apache-2.0
kafka-python
18.5M
5.9KNov 2026Apache-2.0
aiokafka
15.0M
1.4KOct 2026Apache-2.0
FastStream
1.9M
5.4KOct 2026Apache-2.0
faust-streaming
288.1K
1.9KOct 2026BSD-3-Clause
Quix Streams
86.3K
1.6KOct 2026Apache-2.0
Arroyo
26.4K
63Nov 2026Apache-2.0
PyKafka
16.8K
1.1KSep 2018Apache-2.0
Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

confluent-kafka

Provides Kafka producer, consumer, and administration APIs backed by librdkafka.

Downloads / mo
46.4M
Stars
528
Last release
2.16.2
License
Apache-2.0

Strengths

  • Provides an asyncio producer. Use the asynchronous producer inside applications with an asyncio event loop.
  • Supports transactional Kafka workflows. Use the client transaction APIs for atomic Kafka processing.

Limitations

  • Async batching omits message headers. Use synchronous produce when each message needs headers.
  • Delivery callbacks need polling. Poll the synchronous producer to run queued delivery callbacks.

Quickstart

From README.md
$ pip install confluent-kafka
import asyncio
from confluent_kafka.aio import AIOProducer

async def main():
    p = AIOProducer({"bootstrap.servers": "mybroker"})
    try:
        # produce() returns a Future; first await the coroutine to get the Future,
        # then await the Future to get the delivered Message.
        delivery_future = await p.produce("mytopic", value=b"hello")
        delivered_msg = await delivery_future
        # Optionally flush any remaining buffered messages before shutdown
        await p.flush()
    finally:
        await p.close()

asyncio.run(main())

confluent-kafka examples

From open-source projects on GitHub

Provides pure-Python Kafka producer, consumer, and administration clients.

Downloads / mo
18.5M
Stars
5.9K
Last release
3.0.13
License
Apache-2.0

Strengths

  • Installs without a native core. Use producer, consumer, and admin clients without a compiled client dependency.
  • Supports transactional message publishing. Commit or abort the messages sent within a producer transaction.

Limitations

  • Consumers belong to one thread. Keep each consumer instance within its own thread.
  • Waiting for delivery blocks. Keep blocking future waits outside an application event loop.

Quickstart

From example.py
$ pip install kafka-python
# Serialize json messages
from kafka import KafkaProducer, JsonSerializer
producer = KafkaProducer(value_serializer=JsonSerializer())
producer.send('fizzbuzz', {'foo': 'bar'})

kafka-python examples

From open-source projects on GitHub

Provides asyncio producer and consumer APIs for Apache Kafka.

Downloads / mo
15.0M
Stars
1.4K
Last release
0.15.0
License
Apache-2.0

Strengths

  • Fits async producer lifecycles. Await producer startup, delivery, and shutdown from the application event loop.
  • Coordinates consumer groups. Distribute topic partitions among consumers in the same group.

Limitations

  • Producer memory limit needs handling. Manage total buffered data outside the missing buffer.memory setting.
  • Send timeouts need explicit wrapping. Wrap producer.send with asyncio.wait_for when a bounded wait is required.

Quickstart

From README.rst
$ pip install aiokafka
from aiokafka import AIOKafkaProducer
import asyncio

async def send_one():
    producer = AIOKafkaProducer(bootstrap_servers='localhost:9092')
    # Get cluster layout and initial topic/partition leadership information
    await producer.start()
    try:
        # Produce message
        await producer.send_and_wait("my_topic", b"Super message")
    finally:
        # Wait for all pending messages to be delivered or expire.
        await producer.stop()

asyncio.run(send_one())

aiokafka examples

From open-source projects on GitHub

FastStream

Connects to Kafka, RabbitMQ, NATS, Redis, and MQTT through one typed client.

Downloads / mo
1.9M
Stars
5.4K
Last release
0.7.8
License
Apache-2.0

Quickstart

From README.md
$ pip install 'faststream[kafka,cli]'
from faststream import FastStream
from faststream.kafka import KafkaBroker
# from faststream.confluent import KafkaBroker
# from faststream.rabbit import RabbitBroker
# from faststream.nats import NatsBroker
# from faststream.redis import RedisBroker
# from faststream.mqtt import MQTTBroker

broker = KafkaBroker("localhost:9092")
# broker = RabbitBroker("amqp://guest:guest@localhost:5672/")
# broker = NatsBroker("nats://localhost:4222/")
# broker = RedisBroker("redis://localhost:6379/")
# broker = MQTTBroker("localhost")

app = FastStream(broker)

@broker.subscriber("in")
@broker.publisher("out")
async def handle_msg(user: str, user_id: int) -> str:
    return f"User: {user_id} - {user} registered"

faust-streaming

Processes streams in Python as a fork of Faust.

Downloads / mo
288.1K
Stars
1.9K
Last release
0.15.4
License
BSD-3-Clause

Quickstart

From hello_world.py
$ pip install faust-streaming
import faust

app = faust.App(
    'hello-world',
    broker='kafka://localhost:9092',
    value_serializer='raw',
)

greetings_topic = app.topic('greetings')

@app.agent(greetings_topic)
async def greet(greetings):
    async for greeting in greetings:
        print(greeting)

Quix Streams

Builds stateful stream-processing pipelines and Kafka producer-consumer applications in Python.

Downloads / mo
86.3K
Stars
1.6K
Last release
3.28.1
License
Apache-2.0

Strengths

  • Builds streaming dataframe pipelines. Transform, filter, and publish Kafka messages through dataframe operations.
  • Persists state across application restarts. Keep keyed application state locally with Kafka changelog backups.

Limitations

  • State stays scoped by key. Read or update keyed state only while processing that same message key.
  • Exactly-once processing needs configuration. Select exactly-once explicitly when the default at-least-once behavior does not fit.

Quickstart

From README.md
$ python -m pip install quixstreams
from quixstreams import Application

app = Application(broker_address="localhost:9092")
topic = app.topic("input")

with app.get_producer() as producer:
    producer.produce(topic=topic.name, key=b"key", value=b"value")

Works with streaming data in Python.

Downloads / mo
26.4K
Stars
63
Last release
2.49.2
License
Apache-2.0

Quickstart

From getstarted.rst
$ pip install sentry-arroyo
from arroyo.backends.kafka.configuration import (
    build_kafka_consumer_configuration,
)
from arroyo.backends.kafka.consumer import KafkaConsumer
from arroyo.types import Topic

TOPIC = Topic("source-topic")

consumer = KafkaConsumer(
    build_kafka_consumer_configuration(
        default_config={},
        bootstrap_servers=["127.0.0.1:9092"],
        auto_offset_reset="latest",
        group_id="test-group",
    )
)

consumer.subscribe([TOPIC])

while True:
    msg = consumer.poll(timeout=1.0)
    if msg is not None:
        print(f"MSG: {msg.payload}")

Implements a Kafka client in pure Python.

Downloads / mo
16.8K
Stars
1.1K
Last release
2.8.0
License
Apache-2.0

Quickstart

From README.rst
$ pip install pykafka
from pykafka import KafkaClient
client = KafkaClient(hosts="127.0.0.1:9092,127.0.0.1:9093,...")

client.topics

FAQ

confluent-kafka suits most production services, with producer, consumer, and administration APIs backed by librdkafka. aiokafka suits asyncio applications. kafka-python suits environments that need a pure Python client.

confluent-kafka is a Python client for Kafka with producer, consumer, and administration APIs backed by librdkafka. Its AIOProducer offers awaitable calls for asyncio code.

FastStream is a typed Python client for Kafka, RabbitMQ, NATS, Redis, and MQTT with awaitable publishing and subscription handlers. Its default Kafka module runs on aiokafka.

kafka-python is a Kafka client written in pure Python with producer, consumer, and administration APIs. Its public API is synchronous and blocking.

A consumer subscribes to topics and polls for messages in a loop. confluent-kafka and kafka-python offer blocking consumers. aiokafka offers the same pattern as an asyncio consumer.

For coding agents

Found your kafka library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official