Registry / type-stubs / types-confluent-kafka

types-confluent-kafka

JSON →
library1.4.1pypypi✓ verified 24d ago

This package provides type hints for the `confluent-kafka` Python client, enhancing development experience with static type checking (e.g., with mypy) and improved auto-completion in IDEs. It follows Semantic Versioning 2.0.0 and is released frequently to stay updated with `confluent-kafka` changes. As of `confluent-kafka-python` v2.13.0+, the official library includes its own type hints, making this package primarily relevant for users on older `confluent-kafka` versions.

pip install --no-cache-dir types-confluent-kafka
INSTALL
IMPORT
SIG · TYPES-CONFLUENT-KA
T
types-confluent-kafka
type-stubspythonv1.4.1
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.4.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Producer
from confluent_kafka import Producer
Types from `types-confluent-kafka` are 'injected' into the `confluent_kafka` module upon installation.
Consumer
from confluent_kafka import Consumer
Types from `types-confluent-kafka` are 'injected' into the `confluent_kafka` module upon installation.

This quickstart demonstrates how to import and use `Producer` and `Consumer` with type hints, leveraging the `types-confluent-kafka` package. The type hints become available directly through the `confluent_kafka` module. To run this, ensure a Kafka broker is accessible at the specified `bootstrap.servers` (defaulting to `localhost:9092`).

from confluent_kafka import Producer, Consumer import os # Configure Kafka broker(s) bootstrap_servers = os.environ.get('KAFKA_BOOTSTRAP_SERVERS', 'localhost:9092') # Producer with type hints producer: Producer = Producer({'bootstrap.servers': bootstrap_servers}) print(f"Producer created with bootstrap servers: {bootstrap_servers}") # Consumer with type hints consumer: Consumer = Consumer({'bootstrap.servers': bootstrap_servers, 'group.id': 'my-group'}) print(f"Consumer created with bootstrap servers: {bootstrap_servers} and group.id: my-group") # Example of how to use with mypy (run 'mypy your_kafka_application.py' in terminal)
Debug
Known issues
deprecatedThis package is largely deprecated for `confluent-kafka-python` versions 2.13.0 and above, as the official `confluent-kafka-python` library now includes its own integrated type hints. Users on newer `confluent-kafka-python` versions should prefer the official type hints.
fix
For `confluent-kafka-python` v2.13.0 and newer, remove `types-confluent-kafka` and rely on the built-in type hints. For older versions, continue using this package.
affects: >=2.13.0 of `confluent-kafka-python`
gotchaThis package provides type hints for the `confluent-kafka` library, but does not provide the `confluent-kafka` library itself. Users must install `confluent-kafka` separately. Additionally, `confluent-kafka` itself has experimental and deprecated classes (e.g., `SerializingProducer`, `DeserializingConsumer` are experimental; `AvroConsumer`, `AvroProducer` are deprecated). The types in `types-confluent-kafka` will reflect these underlying library statuses.
fix
Ensure `confluent-kafka` is installed alongside `types-confluent-kafka`. Consult the `confluent-kafka` documentation for best practices regarding its experimental and deprecated features to avoid future breaking changes or issues.
affects: All versions
breakingWhen upgrading `confluent-kafka`, be aware of its own breaking changes. For example, `confluent-kafka` 1.8.2 introduced a mandatory `use.deprecated.format` option for `ProtobufSerializer` and `ProtobufDeserializer`. While `types-confluent-kafka` does not introduce these changes, the types it provides will reflect the API of the underlying `confluent-kafka` version.
fix
Always review the `CHANGELOG` of the `confluent-kafka` library when upgrading and update your code accordingly. Ensure the version of `types-confluent-kafka` is compatible with your `confluent-kafka` version.
affects: Relevant `confluent-kafka` versions (e.g., `confluent-kafka` 1.8.2 and later for `ProtobufSerializer` changes)
Upgrade
Version history
1.4.1latest on PyPI · released Mar 9, 2026
Audit
Dependencies
confluent-kafkarequiredThis package provides type hints for `confluent-kafka` and is therefore implicitly dependent on its presence. Users should install `confluent-kafka` separately. This package is intended for `confluent-kafka` versions below 2.13.0.
Agent activity
22 hits · last 30 days
node
20
OpenAI (training)
1
Resources
types-confluent-kafka — pip install types-confluent-kafka · libregistry