> ## Documentation Index
> Fetch the complete documentation index at: https://docs.elanotes.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Python SDK

> elanotes — typed httpx client generated from the committed OpenAPI document.

`elanotes` (`sdks/python`) is generated with `openapi-python-client`
and wrapped for automatic `Idempotency-Key` plus `ElanotesError`
(`reason`, `hint`, `help`, `retry_after_seconds`, `details`).

PyPI publish is post-v1. Production is
`Client("https://api.elanotes.com", token=…)` — no `/v1` suffix. The
samples below use the local origin.

```bash theme={null}
uv run --project sdks/python python -c "from elanotes import Client; print(Client)"
```

## Search

```python theme={null}
from elanotes import Client

with Client("http://localhost:4000") as client:
    results = client.search_notes("Paddle", limit=5)
    print(results["results"][0]["provenance"]["slug"])
```

## Create with Idempotency-Key

```python theme={null}
import uuid
from elanotes import Client

with Client("http://localhost:4000") as client:
    receipt = client.write_note(
        "agents/hello.md",
        "---\ntitle: Hello\n---\n\n# Hello\n",
        agent_id="readme",
        idempotency_key=str(uuid.uuid4()),
    )
    print(receipt["slug"], receipt["version_id"])
```

Writes without `idempotency_key` still send a generated UUID.

## Handle VERSION\_MOVED via hint

```python theme={null}
from elanotes import Client, ElanotesError

with Client("http://localhost:4000") as client:
    note = client.read_note("hello")
    try:
        client.edit_note(
            "hello",
            version_id="00000000-0000-4000-8000-000000000000",
            old_string="Hello",
            new_string="Hello again",
            agent_id="readme",
        )
    except ElanotesError as exc:
        if exc.reason == "VERSION_MOVED":
            print(exc.hint)
            client.edit_note(
                "hello",
                version_id=note["version_id"],
                old_string="Hello",
                new_string="Hello again",
                agent_id="readme",
            )
```

Regenerate: `node scripts/sdk-generate.mjs --python`. Same contract as
the [TypeScript SDK](/sdk-ts).
