Getting started with Python.
Install one package, connect with your service key, and store your first sealed record in about forty lines of asyncio Python.
asyncio · cryptography 48+
1. Install the package
pip install vaultdb-client==0.6.1 installs the package from PyPI. It requires Python 3.14 and cryptography (48 or newer) and brings websockets.
2. Get a server to talk to
To try it, run a test server on your machine: vaultdb-hosted --memory keeps nothing on disk and prints its service card on its first line. Save that line in service-card.json. Make your service key once with vaultdb.generate_service_key() and keep its secret in service-key.hex as hex. For real use, write to us: send us only the public half of your service key, and we send you your card.
3. Run the example
It connects, creates a vault whose key you derive yourself, puts a note, searches it back, stores a file and reads it back, and reads the audit trail.
import asyncio
import io
import json
import vaultdb
from cryptography.hazmat.primitives.kdf.scrypt import Scrypt
async def main(card: dict, secret: bytes) -> None:
# Your vault's key: 32 bytes made on your side. The service never sees it.
k = Scrypt(salt=b"my app, vault 1", length=32, n=2**14, r=8, p=1).derive(
b"a long passphrase only the app knows")
async with await vaultdb.connect(card, secret) as conn:
declaration = {"types": {"note": {"parents": [""], "fields": {"title": {"exact": True}, "text": {}}}}}
vault = await conn.create_vault(k, declaration, actor="alice")
# Put a note: "indexed" values can be searched, the bytes are yours.
note = vaultdb.Item("note", {"title": "Hello"}, b"my first note")
put = await vault.put(note, actor="alice")
# Search it back.
found = await vault.search("note", [vaultdb.Condition("title", "exact", "Hello")], actor="alice")
print("found:", found.items[0].app.decode())
# Put a file on the note, and read it back into any file-like object.
data = b"the contents of a file" * 1000
await vault.file_put(put.id, note.crid, io.BytesIO(data), len(data),
name="hello.txt", type="text/plain", actor="alice")
listing = await vault.file_list(put.id, note.crid, actor="alice")
out = io.BytesIO()
await vault.file_read(listing.items[0].info, note.crid, out, actor="alice")
print("file:", listing.items[0].meta.name, len(out.getvalue()), "bytes")
# Who did what: the audit trail.
for event in (await vault.audit_read(actor="alice")).events:
print("audit:", event.actor, event.op)
if __name__ == "__main__":
card = json.load(open("service-card.json")) # the card your service gave you
secret = bytes.fromhex(open("service-key.hex").read().strip()) # from vaultdb.generate_service_key()
asyncio.run(main(card, secret))4. What it prints
found: my first note, file: hello.txt 22000 bytes, followed by one audit: line for each recorded call (including audit: alice put and audit: alice get_file).
Where your key comes from
You derive the 32-byte vault key on your side from your own secret, as the example does with Scrypt. We never see it. If you lose it, nobody can open the vault, us included.
Files, concurrency, and errors
Every call is a coroutine taking actor= (1 to 128 bytes) and many can run at once on one connection; from a synchronous program, wrap calls in asyncio.run(...). file_put(entry, record_crid, source, size, ...) streams files up to 1 GiB in 4 MiB parts from any seekable binary file object; pass resume=vaultdb.FileUpload() and repeat with the same object after a drop to send only the missing parts. file_read writes to any object with write(bytes) — if it raises, discard what it wrote. Errors are vaultdb.VaultDBError, with code, detail, and next.
When a node changes its key
When a node changes its key, vaultdb.connect follows it by itself — nobody needs a new card. If we switch your vault over to its second copy, the client follows there too. conn.card() returns the current card, and on_card_change= is called once with the updated card as JSON bytes so you can save it; a program that never saves keeps working and learns the new key again on its next start.
Plain tables
A vault also holds plain SQLite tables of your own, for state about no one in particular: counters, queues, slots, settings. vault.plain_query(sql, params, actor=...) reads and vault.plain_tx(statements, actor=...) writes several statements all or nothing, with optional row/change checks. Only the vault's owner may call them. The SQL, its parameters and the rows are readable by the server and are not audited, and a row you delete stays in the vault's log until you shred the vault, so personal data stays in sealed records.