Skip to main content

A well-documented, fully type-hinted Kafka client for Python

Project description

typedkafka

A well-documented, fully type-hinted Kafka client for Python.

Python Version License: MIT

Overview

typedkafka provides a modern Python interface to Apache Kafka with comprehensive documentation, full type hints, and developer-friendly features. Built on confluent-kafka for performance and reliability.

Key Features:

  • Full type hints and comprehensive docstrings
  • JSON, string, and bytes message helpers
  • Transaction support with context managers
  • Async producer and consumer (asyncio)
  • Retry utilities with exponential backoff
  • Pluggable serializer framework (JSON, String, Avro/Schema Registry)
  • Testing utilities (MockProducer/MockConsumer)
  • Type-safe configuration builders with validation
  • Admin client for topic management

Installation

pip install typedkafka

# With Avro/Schema Registry support
pip install typedkafka[avro]

Requires Python 3.9+.

Quick Start

from typedkafka import KafkaProducer

with KafkaProducer({"bootstrap.servers": "localhost:9092"}) as producer:
    producer.send("my-topic", b"Hello, Kafka!")
    producer.send_json("events", {"user_id": 123, "action": "click"})
    producer.flush()
from typedkafka import KafkaConsumer

with KafkaConsumer({"bootstrap.servers": "localhost:9092", "group.id": "my-group"}) as consumer:
    consumer.subscribe(["my-topic"])
    for msg in consumer:
        print(msg.value_as_json())
        consumer.commit(msg)

See the examples/ directory for more: transactions, async, retry, serializers, batch send, testing mocks, and config builders.

Development

git clone https://github.com/Jgprog117/typedkafka.git
cd typedkafka
pip install -e ".[dev]"
pytest
ruff check .
mypy src

License

MIT License - see LICENSE file for details.

Changelog

See CHANGELOG.md for the full release history.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

typedkafka-0.3.3.tar.gz (37.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

typedkafka-0.3.3-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file typedkafka-0.3.3.tar.gz.

File metadata

  • Download URL: typedkafka-0.3.3.tar.gz
  • Upload date:
  • Size: 37.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for typedkafka-0.3.3.tar.gz
Algorithm Hash digest
SHA256 2ee3fc821c9c0c135dd1c79d5281439ee1c7f6aac300677097324460d14ab76c
MD5 988262a4b910df3976bd63eda8bf9915
BLAKE2b-256 51510adb11a55808b1e31ed381f776b70ba706147b8ac9aef54fd9092b803a02

See more details on using hashes here.

Provenance

The following attestation bundles were made for typedkafka-0.3.3.tar.gz:

Publisher: publish.yml on Jgprog117/typedkafka

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file typedkafka-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: typedkafka-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 27.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for typedkafka-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 57db32737cd2be41f2fbf02cebc7b236088f76667da1ac265dcd891b42719b1f
MD5 7d9d0003c38367b90eb0622cb9291eb6
BLAKE2b-256 43dbbb262795e98faa91273731c3f0b53be289056c415df9d5dbee3d09b5dd5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for typedkafka-0.3.3-py3-none-any.whl:

Publisher: publish.yml on Jgprog117/typedkafka

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page