potik
potik is an async Python framework for Kafka services that read records, process them, and write new ones. A handler returns its output records, and potik commits them in one Kafka transaction with the input's offset. Consumers downstream see each output exactly once, even after a crash or a rebalance.
Example
from typing import Annotated
import anyio
from pydantic import BaseModel
import potik
from potik import Config, Key, ProducerRecord, Router, Topic
from potik.serde import PydanticJson
class Order(BaseModel):
sku: str
amount: float
class Accepted(BaseModel):
sku: str
total: float
json = PydanticJson()
orders = Topic("orders", Order, serde=json)
accepted = Topic("orders.accepted", Accepted, serde=json)
router = Router()
@router.handler(orders)
async def accept(order: Order, customer: Annotated[str, Key()]) -> ProducerRecord:
return accepted(Accepted(sku=order.sku, total=order.amount * 1.2), key=customer)
runtime = potik.build_runtime(Config(bootstrap_servers="localhost:9092", group_id="acceptor"), [router])
anyio.run(runtime.run)
Features
- One transactional producer per app commits outputs and offsets for all partitions together (KIP-447).
- Partitions run concurrently, and records within a partition run in order, or with key concurrency, in order per key. A handler can run for minutes without dropping the app from its consumer group.
- A
Topicdeclares its value and key types, and type checkers check every record a handler returns. - Handlers take dependencies in the style of FastAPI's
Depends, e.g. a database transaction that commits or rolls back after each record. - A failing handler stops only its own partition. Middleware adds retries and dead letter topics.
- The app shuts down on SIGTERM after it commits finished work. Its liveness and readiness checks are ready to serve as Kubernetes probes from any HTTP framework.
- OpenTelemetry tracing follows each record through its handler, and its outputs to the transaction that commits them.
Install
potik needs Python 3.12+ and Kafka 4.0+.
uv add "potik[pydantic]"
Documentation
- Quickstart
- Runtime: delivery, failures, configuration, and production
- Middleware: retries, dead letters, concurrency limits, tracing, and metrics
- Typed API: topics, serdes, handlers, and testing
- Producer and request-reply
To contribute, see CONTRIBUTING.md.
Metadata
Release files for potik 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| potik-0.3.0.tar.gz | 139.7 kB | With provenance | Details for potik-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| potik-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for potik-0.3.0-py3-none-any.whl |
Total release size: 234.2 kB
Release files / potik-0.3.0.tar.gz
| Download URL | potik-0.3.0.tar.gz |
|---|---|
| Size | 139.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
58cadb69f4e00e91bce29e9a82f64428788e5fee9c08639dcf9fb783b92739df
|
|
BLAKE2b-256 checksum How to use checksums |
16d4e4a236fc0dd826858da7cefb6ff26525bcab23d1ddbb0c5360b87ad853e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
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 6, 2026.
Transparency logRelease files / potik-0.3.0-py3-none-any.whl
| Download URL | potik-0.3.0-py3-none-any.whl |
|---|---|
| Size | 94.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a303174c0620f9f37d21a296ce764eb957b694c71b17a8de2b07ccfc99a06538
|
|
BLAKE2b-256 checksum How to use checksums |
8a3be587fa2c4e0508d310323e1b5f4c1866b951aab215b4d068d1d70956c085
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
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 6, 2026.
Transparency logSecurity for potik 0.3.0
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
Both files in this release have been uploaded with provenance metadata.
Attestation for potik-0.3.0.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 6, 2026.
Transparency logA 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.