Skip to main content

HEP AI-callable JSON CLI for the official GnuCash engine.

Project description

Gnucash-CLI

CI Release PyPI Python

Gnucash-CLI is the HEP command-line runtime for operating GnuCash books through the official GnuCash engine, not by directly editing SQL tables.

The intended production path is:

AI Agent
  -> JSON CLI
  -> GnuCash official Python bindings
  -> libgnucash engine / QOF Session
  -> GnuCash PostgreSQL backend

No piecash and no SQLAlchemy are used.

Requirements

You need a Python environment where GnuCash official Python bindings are importable:

import gnucash
from gnucash import Session, SessionOpenMode

On Linux this is commonly provided by a package like python3-gnucash, or by building GnuCash with:

cmake -DWITH_PYTHON=ON ...

GnuCash's own docs warn that GnuCash is effectively single-writer; do not run this CLI while the GUI is editing the same book.

Install

From PyPI:

pipx install gnucash-cli

For development:

python -m pip install -e ".[dev]"

Usage

Use a GnuCash URI. For PostgreSQL, pass the URI that your GnuCash build accepts for its SQL backend:

hep-gnucash inspect --book-uri "$GNUCASH_BOOK_URI" --json
hep-gnucash export-ledger --book-uri "$GNUCASH_BOOK_URI" --json
hep-gnucash statements --book-uri "$GNUCASH_BOOK_URI" --json --period month
hep-gnucash analyze --book-uri "$GNUCASH_BOOK_URI" --json --benchmark-file benchmarks/retail.json
hep-gnucash forecast --book-uri "$GNUCASH_BOOK_URI" --json --assumptions-file examples/forecast_assumptions.json

Write commands use official engine object creation/edit/commit:

hep-gnucash account create --book-uri "$GNUCASH_BOOK_URI" --json \
  --name "Platform Fees" --type EXPENSE --parent "Expenses"

hep-gnucash transaction create --book-uri "$GNUCASH_BOOK_URI" --json \
  --date 2026-05-08 --description "Cash sale" \
  --splits '[{"account":"Assets:Cash","value":100},{"account":"Income:Sales","value":-100}]'

JSON Contract

Every command emits JSON to stdout:

{
  "ok": true,
  "command": "inspect",
  "book_uri": "postgres://...",
  "result": {},
  "warnings": [],
  "evidence": []
}

Errors are also structured JSON and return a non-zero exit code.

Safety

For PostgreSQL books there is no file copy backup. Instead, write commands return a mutation log with created GUIDs, affected accounts, and split totals. Use PostgreSQL snapshots/PITR or run against a staging book for recovery-grade workflows.

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

gnucash_cli-0.1.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

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

gnucash_cli-0.1.0-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file gnucash_cli-0.1.0.tar.gz.

File metadata

  • Download URL: gnucash_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gnucash_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a20bdad9d205eaab141bf2a3803070722f27daf694674397f527bf62e5d62115
MD5 26aa67a313ac0bbe4e83c606dcb81aa3
BLAKE2b-256 e4ccd2bd697c80ab4bf29aaf79204e86c502e601e0c6eedc4126fb8d9351116d

See more details on using hashes here.

Provenance

The following attestation bundles were made for gnucash_cli-0.1.0.tar.gz:

Publisher: release.yml on Harry-s-Economics-Program/Gnucash-CLI

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

File details

Details for the file gnucash_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: gnucash_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gnucash_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ce8ce7ee494666eaddd046da61f306dca082a5f0fbc40dc391ab3387ef2a802
MD5 02492c346f70c4364c301460d59a1161
BLAKE2b-256 1dae57b94d15be982f0cb8466ae9e9f3c22d2075ce30e69df6b1ffabb4bf7404

See more details on using hashes here.

Provenance

The following attestation bundles were made for gnucash_cli-0.1.0-py3-none-any.whl:

Publisher: release.yml on Harry-s-Economics-Program/Gnucash-CLI

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