Skip to main content

pyrkafka: Fast Python Kafka Client Powered by Rust

PyPI version License

pyrkafka is a fast, lightweight Python client for Apache Kafka, built on top of librdkafka via the Rust rdkafka crate. It provides a simple, Pythonic API for producing and consuming Kafka messages with native Rust performance through PyO3.

Features

  • Rust-powered performance — wraps librdkafka through Rust, avoiding the overhead of pure-Python implementations
  • GIL release during polling — consumer polling releases the Python GIL, allowing other threads to run while waiting for messages
  • Simple Pythonic API — producer and consumer with familiar Python patterns (for and async for for consuming)
  • Full librdkafka configuration — pass any librdkafka config option via a dict
  • SSL and compression built-in — compiled with SSL (vendored OpenSSL) and zstd compression support
  • Cross-platform wheels — pre-built for Linux (x86_64, aarch64), macOS (x86_64, Apple Silicon), and Windows

Installation

pip install pyrkafka

Requires Python 3.13+. Pre-built wheels are available for all major platforms — no Rust toolchain needed for installation.

Getting Started

Producing Messages

from pyrkafka import PyrKafkaProducer

producer = PyrKafkaProducer("localhost:9092")

# Send a message (partitioned round-robin)
producer.produce("my_topic", b"Hello, Kafka!")

# Send with a key (messages with the same key go to the same partition)
producer.produce_with_key("my_topic", b"Hello, Kafka!", "my_key")

# Flush pending messages (also happens automatically when the producer is dropped)
producer.flush()

Consuming Messages

from pyrkafka import PyrKafkaConsumer

consumer = PyrKafkaConsumer("localhost:9092", "my_topic", "my_group")

for message in consumer:
    print(message.decode())

Async Consuming

The consumer supports async for for use in asyncio applications. The blocking Kafka poll is automatically offloaded to a thread so the event loop stays responsive:

import asyncio
from pyrkafka import PyrKafkaConsumer

async def main():
    consumer = PyrKafkaConsumer("localhost:9092", "my_topic", "my_group")
    async for message in consumer:
        print(message.decode())

asyncio.run(main())

Custom Configuration

Both producer and consumer accept an optional config dict for additional librdkafka configuration:

producer = PyrKafkaProducer("localhost:9092", config={
    "message.timeout.ms": "5000",
    "compression.type": "zstd",
})

consumer = PyrKafkaConsumer("localhost:9092", "my_topic", "my_group", config={
    "auto.offset.reset": "latest",
    "enable.auto.commit": "false",
})

License

MIT

Metadata

Release files for pyrkafka 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyrkafka 0.3.1
File Size Uploaded Provenance Actions
pyrkafka-0.3.1.tar.gz 13.4 kB With provenance Details for pyrkafka-0.3.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pyrkafka 0.3.1
File Actions
pyrkafka-0.3.1-cp313-abi3-win_amd64.whl CPython 3.13 abi3 Windows x86-64 Details for pyrkafka-0.3.1-cp313-abi3-win_amd64.whl
pyrkafka-0.3.1-cp313-abi3-manylinux_2_28_x86_64.whl CPython 3.13 abi3 Linux glibc 2.28+ x86-64 Details for pyrkafka-0.3.1-cp313-abi3-manylinux_2_28_x86_64.whl
pyrkafka-0.3.1-cp313-abi3-manylinux_2_28_aarch64.whl CPython 3.13 abi3 Linux glibc 2.28+ ARM64 Details for pyrkafka-0.3.1-cp313-abi3-manylinux_2_28_aarch64.whl
pyrkafka-0.3.1-cp313-abi3-macosx_11_0_arm64.whl CPython 3.13 abi3 macOS 11.0+ ARM64 Details for pyrkafka-0.3.1-cp313-abi3-macosx_11_0_arm64.whl
pyrkafka-0.3.1-cp313-abi3-macosx_10_12_x86_64.whl CPython 3.13 abi3 macOS 10.12+ x86-64 Details for pyrkafka-0.3.1-cp313-abi3-macosx_10_12_x86_64.whl

Total release size: 18.2 MB

Release files / pyrkafka-0.3.1.tar.gz

Download URL pyrkafka-0.3.1.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2c856cb0a6e0bace6fa336458fdbe63bc67482350cdbefad99478cd11b159c30
BLAKE2b-256 checksum
How to use checksums
dd29b2ae0477ccdc6ef3f35d6d2037726a044d38c9cbb882029cbbacf25fec8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / pyrkafka-0.3.1-cp313-abi3-win_amd64.whl

Download URL pyrkafka-0.3.1-cp313-abi3-win_amd64.whl
Size 3.5 MB
Tags CPython 3.13 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
c8a83e020bced15be960bc80961653b262d92b43f7b3670872a35fa545f89318
BLAKE2b-256 checksum
How to use checksums
27f6c3fb0cabf9ee07f142e6568398a184e1eb10998a392c3e5fb33b62624621
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / pyrkafka-0.3.1-cp313-abi3-manylinux_2_28_x86_64.whl

Download URL pyrkafka-0.3.1-cp313-abi3-manylinux_2_28_x86_64.whl
Size 3.9 MB
Tags CPython 3.13 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
9bc63ac42da227f8f812df902f6b3aec1dd23adff8144b15614be8faf350b053
BLAKE2b-256 checksum
How to use checksums
fca1dc4c6a2b03f289f322a96dcd7b13b9599e3809e7560ad13d2d2618abf95b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / pyrkafka-0.3.1-cp313-abi3-manylinux_2_28_aarch64.whl

Download URL pyrkafka-0.3.1-cp313-abi3-manylinux_2_28_aarch64.whl
Size 4.0 MB
Tags CPython 3.13 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
89e98e8c24336e33732bc985941e18d92fb9dafd3c4d2b251e882fa632bc8c41
BLAKE2b-256 checksum
How to use checksums
a77b3c8f38ea4ff121debfd2ee231fc73360d6772379cd3942ea2191710f3061
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / pyrkafka-0.3.1-cp313-abi3-macosx_11_0_arm64.whl

Download URL pyrkafka-0.3.1-cp313-abi3-macosx_11_0_arm64.whl
Size 3.4 MB
Tags CPython 3.13 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a6f4d4ad3baaaaf3d01ebb71881a86bfb625ce61ecea7febefa1bb66b090dad8
BLAKE2b-256 checksum
How to use checksums
6e498537b0bd7be997b7b6819d3c9ba04b9891a75881d8b88bf4acb50daf628b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / pyrkafka-0.3.1-cp313-abi3-macosx_10_12_x86_64.whl

Download URL pyrkafka-0.3.1-cp313-abi3-macosx_10_12_x86_64.whl
Size 3.3 MB
Tags CPython 3.13 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
91ad872a1b10d74c4c6c0d836ff35883a1443ede4e3c8e2202db82b211a8ceba
BLAKE2b-256 checksum
How to use checksums
cc2239c482e270ef815da9573e6ad53ae6685571cf645bafdbd9701360f0e88c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Security for pyrkafka 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for pyrkafka-0.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page