Skip to main content

Python library for the KeePassXC browser extension protocol

Project description

KeePassXC Browser API

Python library for communicating with KeePassXC via the browser extension protocol (NaCl-encrypted JSON over a Unix socket).

Features

  • NaCl-encrypted communication with KeePassXC
  • One-time association flow (user approves in KeePassXC window)
  • Biometric unlock (TouchID / system unlock) via triggerUnlock
  • Full browser API support: read entries, write entries, manage groups, TOTP, password generation, lock database
  • Cross-platform: macOS and Linux
  • Shared config (~/.keepassxc/browser-api.json) — associate once, use with all tools

Installation

pip install keepassxc-browser-api

Quick start

from keepassxc_browser_api import BrowserClient, BrowserConfig

config = BrowserConfig.load()
client = BrowserClient(config)

# First time: associate with KeePassXC (requires user approval)
if not config.associations:
    client.setup()
    config.save()

# API methods auto-connect, auto-unlock (triggers TouchID/biometrics if locked),
# and verify the association before every call
entries = client.get_logins("https://example.com")
for e in entries:
    print(e.name, e.login)

# Clean up when done
client.disconnect()

Or use the context manager for automatic cleanup:

with BrowserClient(config) as client:
    entries = client.get_logins("https://example.com")
    totp = client.get_totp(entries[0].uuid)

API

BrowserClient

Method Description
setup() First-time association (user approves in KeePassXC)
ensure_unlocked() Connect and unlock (triggers TouchID if locked)
get_logins(url, ...) Find entries matching a URL
set_login(url, username, password, ...) Create or update an entry
get_database_entries() Return all entries
get_database_groups() Return all groups (tree)
create_group(name, parent_uuid) Create a new group
get_totp(uuid) Get TOTP code for an entry
delete_entry(uuid) Delete an entry
lock_database() Lock the database
generate_password() Generate a password (uses KeePassXC settings)
request_autotype(search) Trigger KeePassXC global auto-type

Note: passkeys-get and passkeys-register are not implemented. They require complex WebAuthn/CBOR data structures and are only available in KeePassXC builds compiled with WITH_XC_BROWSER_PASSKEYS.

BrowserConfig

Configuration stored at ~/.keepassxc/browser-api.json (mode 0600).

config = BrowserConfig.load()        # Load from default path
config = BrowserConfig.load(path)    # Load from custom path
config.save()                        # Save to default path
config.save(path)                    # Save to custom path

Protocol documentation

For a detailed description of the KeePassXC browser extension protocol (wire format, encryption, all actions, error codes), see PROTOCOL.md.

Development

# Install in editable mode with dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run tests with coverage
pytest --cov=keepassxc_browser_api

# Lint
ruff check --ignore=E501 --exclude=__init__.py ./keepassxc_browser_api

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

keepassxc_browser_api-1.0.0.tar.gz (27.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

keepassxc_browser_api-1.0.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file keepassxc_browser_api-1.0.0.tar.gz.

File metadata

  • Download URL: keepassxc_browser_api-1.0.0.tar.gz
  • Upload date:
  • Size: 27.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for keepassxc_browser_api-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9d48611a6f6c83b951c1f2e7654070cee51eab33ed5625fe285ff280ccfefb4b
MD5 32ad58a01fa7cd961c7038d7a505b5da
BLAKE2b-256 6a0f7140a8f5c0eca859896ae50bcbf9074bbd25a58e9da4c7b9724e5f6a6281

See more details on using hashes here.

Provenance

The following attestation bundles were made for keepassxc_browser_api-1.0.0.tar.gz:

Publisher: pypi.yml on mietzen/keepassxc-browser-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file keepassxc_browser_api-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for keepassxc_browser_api-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9807a3ba2cf65d298c04653ed095136f8026d9e5d8ab93f14ed571a99d0d2e98
MD5 1c85fdb9bc75c8f0bdd4c369bd9911b2
BLAKE2b-256 b8ef988553043ecdd0053e157476e150b21329dcdb95ad2c0794bfbbf398eeb5

See more details on using hashes here.

Provenance

The following attestation bundles were made for keepassxc_browser_api-1.0.0-py3-none-any.whl:

Publisher: pypi.yml on mietzen/keepassxc-browser-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page