Skip to main content

pylekto

Async Python client for the Lekto DMS REST API.

import asyncio

from pylekto import LektoClient


async def main() -> None:
    async with LektoClient("https://lekto.example.com", "lekto_…") as lekto:
        me = await lekto.auth.me()
        print(me.user.username, me.token_scope)

        async for document in lekto.documents.list(lane=["red"]):
            print(document.title)

        result = await lekto.search.page("electricity bill", limit=5)
        print([hit.document.title for hit in result.items])

        async for event in lekto.events.listen():  # until Lekto ends the stream
            print(event.type, event.document_id)


asyncio.run(main())
  • Token only. A personal API token from Lekto; its scope (read, upload, read_write) decides what the client may do.
  • Your own httpx2 client if you like (LektoClient(url, token, client=...)): pylekto sends its requests with it and leaves it open.
  • Errors raise. Each subclass of LektoError says what went wrong; a refusal carries Lekto's problem details with a reason code. pylekto repeats nothing: whether to try again is up to you.
  • One Lekto release. pylekto speaks the API of pylekto.LEKTO_VERSION; its models are generated from that release's OpenAPI description. While Lekto is in beta, each release may change its API, so connecting to another version warns (LektoVersionWarning).

Receiving webhooks

Lekto signs what it sends to a webhook (Standard Webhooks). In whatever web framework receives it:

from pylekto import webhooks
from pylekto.models import TaskAnswer


async def receive(headers: dict[str, str], body: bytes) -> None:
    webhooks.verify(headers, body, "whsec_…")  # raises WebhookVerificationError
    asked = webhooks.read_rule_ask(body)  # or read_event, read_rule_send, read_propose …
    task = webhooks.task(headers)
    if task is not None:
        await webhooks.answer(task, TaskAnswer(status="ok", answer={"paid": True}))

Requirements

Python 3.14 or newer.

Development

Open the repository in its devcontainer (.devcontainer/); it runs script/setup, which installs the dependencies and the Git hooks. Outside the devcontainer, script/setup creates a local .venv first.

uv sync
uv run prek run --all-files   # every check: Ruff, mypy, pytest with coverage, typos, yamllint

License

MIT, see LICENSE.

Metadata

Release files for pylekto 0.1.0

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

Source distribution (sdist)

Source distribution for pylekto 0.1.0
File Size Uploaded Provenance Actions
pylekto-0.1.0.tar.gz 97.7 kB With provenance Details for pylekto-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pylekto 0.1.0
File Interpreter ABI Platform Actions
pylekto-0.1.0-py3-none-any.whl Python 3 none any Details for pylekto-0.1.0-py3-none-any.whl

Total release size: 205.5 kB

Release files / pylekto-0.1.0.tar.gz

Download URL pylekto-0.1.0.tar.gz
Size 97.7 kB
Tags Source
SHA-256 checksum
How to use checksums
aa239b71568a945cee5dd76152e874f36a4b94f6e3c7aa2b264d0440a366bd49
BLAKE2b-256 checksum
How to use checksums
ca7711f4f781a9b884fb7692ca1ac30ebbb8099c2094804034b3d46db2127310
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 19, 2026.

Transparency log

Release files / pylekto-0.1.0-py3-none-any.whl

Download URL pylekto-0.1.0-py3-none-any.whl
Size 107.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d08657c653ecfbc30ee323a5e9db843a2b577e50bb6ccec2c1fdde0afa9a837
BLAKE2b-256 checksum
How to use checksums
cc3d86d93d7741aec50da1c2539f9ab9361a0c33b45fe4f8d3856d9cdda264bd
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 19, 2026.

Transparency log

Security for pylekto 0.1.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.

Select from 2 files

Attestation for pylekto-0.1.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 19, 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