nse-xbrl-parser is an offline-taxonomy NSE XBRL parser library for Python.
It is built for the common NSE failure mode where filings reference historical or incomplete taxonomy dependencies. The package ships a bundled taxonomy archive and resolves schemas locally, so Arelle validation and fact extraction do not depend on live taxonomy hosting.
uv add git+https://github.com/eggmasonvalue/nse-xbrl-parser.gitparse_xbrl_facts(path)- Returns a context-preserving fact table (
list[dict]) with one row per concept/value/context/unit/decimals/period/basis/dimensions. - Use this for programmatic analytics and any workflow that must preserve every XBRL context.
- Returns a context-preserving fact table (
build_xbrl_view(path, *, include_trace=False, include_validations=True, validate=True, use_cache=True)- Returns a taxonomy-backed, JSON-serializable human view with
title,unit,columns,sections, andchecks. - Uses presentation and calculation linkbases when available, and falls back to safe period/basis/dimension grouping when presentation linkbases are absent.
- Loads the Arelle model once and memoizes the result in-process (keyed by file identity and options). Pass
validate=Falseto skip Arelle's full validation pass (measured ~5x faster on announcement filings; off by default until correctness parity is proven on linkbase-bearing statements). Passuse_cache=Falseto force a fresh load.
- Returns a taxonomy-backed, JSON-serializable human view with
render_xbrl_markdown(view)- Pure renderer from a
build_xbrl_viewdictionary to a readable markdown document. - Use this for human review, document stores, and doc-RAG/NotebookLM ingestion.
- Pure renderer from a
load_xbrl_model(path)- Low-level context manager for advanced callers that need one shared Arelle model load.
clear_view_cache()- Clears the in-process
build_xbrl_viewcache (for long-lived processes, tests, or refreshed taxonomy data).
- Clears the in-process
The library intentionally does not expose a flat {label: value} parser. Any label-to-column flattening is an application-level projection built locally from the structured view or the fact table.
from pathlib import Path
from nse_xbrl_parser import build_xbrl_view, parse_xbrl_facts, render_xbrl_markdown
xml_path = Path("filing.xml")
facts = parse_xbrl_facts(xml_path)
view = build_xbrl_view(xml_path)
markdown = render_xbrl_markdown(view)For an application-local label projection, walk view["sections"][*]["rows"] and copy the labels and values you explicitly want. Keep that flattening in the application so context-collapsing choices remain visible.
uv sync
uv run ruff check .
uv run pytest -q
npx --yes markdownlint-cli2 AGENTS.md README.md context/**/*.md- Agent entrypoint:
AGENTS.md - Code map:
context/MAP.md - Durable tradeoffs:
context/DECISIONS.md - Imperative coding rules:
context/CONVENTIONS.md