From bd5fd5db92a502020e736907632ac7df332a50a4 Mon Sep 17 00:00:00 2001 From: "Joseph T. French" Date: Sun, 4 Oct 2026 20:56:41 -0500 Subject: [PATCH] docs(readme): a Python example that runs The library snippet passed a `filing_meta` it never defined, so it could not run as written. It now loads through FilingSession, which resolves a ticker, accession, LEI or path the way `view` and `serve` do and needs no extra, and names the Arelle-level load_model / to_xbrl_model pair for a host with its own Arelle. The CLI list in Install also gains `view`. --- README.md | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ead2565..b65d3bb 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ behind `xbrlkit view` and the `view_filing` tool. pip install xbrlkit ``` -Exposes the `xbrlkit` CLI (`build`, `fetch`, `query`, `cache`, `serve`) and the +Exposes the `xbrlkit` CLI (`build`, `fetch`, `query`, `view`, `cache`, `serve`) and the library. Three optional extras: `xbrlkit[lpg]` for the property graph as a LadybugDB database and for querying it (pyarrow, LadybugDB), `xbrlkit[icebug]` for the same graph as an experimental icebug-disk tree (pyarrow only) and `xbrlkit[mcp]` for @@ -144,17 +144,26 @@ xbrlkit serve ./mmm-20241231.htm From a source checkout, `just` wraps the same CLI: `just build 320193 0000320193-23-000106` and `just fetch NVDA`. +As a library, a `FilingSession` resolves a filing the way `view` and `serve` +do, with no extra installed: + ```python -from xbrlkit.parse import load_model, to_xbrl_model -from xbrlkit.serialize import to_holon, to_tavi_report from xbrlkit.deserialize import from_holon_json - -model = to_xbrl_model(load_model("mmm-20241231.htm"), filing_meta) -holon = to_holon(model) -tavi, gaps = to_tavi_report(model) -model = from_holon_json(holon) # and back again +from xbrlkit.serialize import to_holon, to_tavi_report +from xbrlkit.serve import FilingSession + +session = FilingSession() +model = session.load("NVDA").model # or "NVDA 10-Q", "cik:accession", "lei:…", a path +holon = to_holon(model) # holon.jsonld text +tavi, gaps = to_tavi_report(model) # the TAVI model, and what it could not carry +model = from_holon_json(holon) # and back again +session.close() ``` +A host running its own Arelle goes a level down: `xbrlkit.parse.load_model` +returns the `ModelXbrl`, and `to_xbrl_model(mx, filing)` walks it into the +same model, given the filing's `FilingMeta` (CIK and accession). + ## Serve to an MCP client Two ways to run it. They differ in which process does the fetching, and so in