{"id":3840,"library":"types-confluent-kafka","title":"Types for Confluent Kafka","description":"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.","status":"active","version":"1.4.1","language":"en","source_language":"en","source_url":"https://github.com/benbenbang/types-confluent-kafka.git","tags":["typing","kafka","confluent","stubs","mypy"],"install":[{"cmd":"pip install --no-cache-dir types-confluent-kafka","lang":"bash","label":"Install `types-confluent-kafka`"}],"dependencies":[{"reason":"This 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.","package":"confluent-kafka","optional":false}],"imports":[{"note":"Types from `types-confluent-kafka` are 'injected' into the `confluent_kafka` module upon installation.","symbol":"Producer","correct":"from confluent_kafka import Producer"},{"note":"Types from `types-confluent-kafka` are 'injected' into the `confluent_kafka` module upon installation.","symbol":"Consumer","correct":"from confluent_kafka import Consumer"}],"quickstart":{"code":"from confluent_kafka import Producer, Consumer\nimport os\n\n# Configure Kafka broker(s)\nbootstrap_servers = os.environ.get('KAFKA_BOOTSTRAP_SERVERS', 'localhost:9092')\n\n# Producer with type hints\nproducer: Producer = Producer({'bootstrap.servers': bootstrap_servers})\nprint(f\"Producer created with bootstrap servers: {bootstrap_servers}\")\n\n# Consumer with type hints\nconsumer: Consumer = Consumer({'bootstrap.servers': bootstrap_servers, 'group.id': 'my-group'})\nprint(f\"Consumer created with bootstrap servers: {bootstrap_servers} and group.id: my-group\")\n\n# Example of how to use with mypy (run 'mypy your_kafka_application.py' in terminal)","lang":"python","description":"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`)."},"warnings":[{"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.","message":"This 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.","severity":"deprecated","affected_versions":">=2.13.0 of `confluent-kafka-python`"},{"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.","message":"This 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"When 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.","severity":"breaking","affected_versions":"Relevant `confluent-kafka` versions (e.g., `confluent-kafka` 1.8.2 and later for `ProtobufSerializer` changes)"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}