Skip to main content

statement-fetch

Zero-LLM async fetcher, structural validator, and pluggable sink runner for statements, invoices, and documents from authenticated web portals.

What It's For

Any web portal behind human login/2FA that periodically issues PDFs, CSVs, JSONs, or ZIP archives can be automated as a small deterministic provider plugin — without ever handing credentials or live portal sessions to an LLM:

  • Banking, cards & brokerage: monthly statements, transaction CSVs, trade confirmations, custody and tax reports.
  • Private funds & wealth portals: quarterly partner reports, capital calls, distributions, K-1s, and audit letters.
  • Insurance & healthcare: policy documents, claims summaries, explanation-of-benefits (EOBs), and annual tax certificates from insurer postboxes.
  • Billing, utilities & SaaS/cloud: monthly VAT invoices and usage exports from telecoms, utilities, cloud providers, and SaaS billing portals.
  • Payroll, HR & pensions: payslips, annual wage/tax statements, and retirement or pension summaries.
  • Government, tax & property: tax assessment notices, social-security records, and mortgage/HOA/property-management statements.
  • Downstream pipelines (via statement_fetch.sinks): route verified, SHA-256-hashed manifests directly into personal accounting ledgers, document management systems (e.g. Paperless-ngx), encrypted local folders, or private knowledge bases.

Security Model ("Zero-LLM-in-Portal")

  1. Human sign-in: A real Chromium browser opens the portal's login URL. The human completes authentication and 2FA; no credentials or LLM tokens touch the live session.
  2. Host confinement: Top-level navigations, HTTP 3xx redirects (single/multi-hop and POST), target="_blank" popups, and in-page fetch_bytes() calls are confined to the provider's declared allowed_hosts via Chromium CDP Fetch.enable and context routing.
  3. Deterministic fetch & atomic staging: After is_logged_in() succeeds, deterministic provider code downloads documents into a per-run 0o700 staging directory, validates every artifact using its declared validator (defaulting to non-empty; built-in validators cover PDF, CSV, JSON, and bounded ZIP), writes 0o600 artifacts with SHA-256 digests, and produces a portable manifest.json.
  4. Guaranteed logoff & pluggable sinks: logoff() and browser teardown run in finally: even on error or Ctrl-C. Sinks (statement_fetch.sinks) verify every manifest entry and SHA-256 before delivering.

Installation

Requires Python 3.11+:

pip install "statement-fetch[playwright]"
playwright install chromium

Quickstart (Demo Portal, From a Clone)

Install Chromium into the project environment:

uv run --extra playwright playwright install chromium

In one terminal, start the bundled zero-dependency loopback demo portal:

uv run python -m statement_fetch.demo --port 8765

In another terminal, fetch statements and export them to a local directory with an immutable receipt manifest:

uv run --extra playwright statement-fetch fetch example-bank \
  --opt base_url=http://127.0.0.1:8765 \
  --upload --sink dir --sink-dir ./exported

Verify a staged or exported manifest offline:

uv run statement-fetch upload ./exported/manifest-*.json --local-only --json

Browser Hosts (--host)

statement-fetch supports three built-in browser hosts (all via the optional [playwright] extra, with zero browser extensions or background daemons):

Host Command Best for Confinement
playwright (default) --host playwright Isolated ephemeral Playwright Chromium Full browser-context + CDP Fetch.enable + popup confinement
chrome --host chrome (optional --host-opt profile=<dir>) Installed Google Chrome with a dedicated 0o700 persistent profile (keeps password-manager extensions & trusted-device cookies; no playwright install chromium needed) Full browser-context + CDP Fetch.enable + popup confinement
chrome-attach --host chrome-attach (optional --host-opt cdp_url=...) Attaching to your already-open Chrome via chrome://inspect/#remote-debugging (auto-discovers DevToolsActivePort, never closes Chrome or other tabs) Tab-scoped CDP Fetch.enable (main tab + 3xx redirects + fetch_bytes; shares your live Chrome context)
# Check host readiness (does not require bundled Chromium for chrome / chrome-attach)
statement-fetch doctor --host chrome
statement-fetch doctor --host chrome-attach

# Optional one-time setup for --host chrome (install password-manager extensions into the dedicated profile, then close Chrome)
statement-fetch host-setup chrome

# Run with installed Chrome (persistent dedicated profile)
statement-fetch fetch example-bank --host chrome --opt base_url=http://127.0.0.1:8765

# Attach to your already-running Chrome (enable chrome://inspect/#remote-debugging once)
statement-fetch fetch example-bank --host chrome-attach --opt base_url=http://127.0.0.1:8765

Plugin API (API_VERSION = 1)

Third-party providers, sinks, and browser hosts import from statement_fetch.api (or top-level statement_fetch) and register via Python entry points:

[project.entry-points."statement_fetch.providers"]
my-portal = "my_pkg.provider:MyPortalProvider"

[project.entry-points."statement_fetch.sinks"]
my-sink = "my_pkg.sink:MySink"

[project.entry-points."statement_fetch.hosts"]
my-host = "my_pkg.host:MyHostPlugin"
  • Reference provider: src/statement_fetch/providers/example_bank.py
  • Reference sink: src/statement_fetch/sinks/directory.py
  • Built-in hosts: PlaywrightHostPlugin, ChromeHostPlugin, CdpChromeHostPlugin in statement_fetch.api
  • Versioning: the entry-point group names (statement_fetch.providers, statement_fetch.sinks, statement_fetch.hosts) define the API_VERSION = 1 compatibility boundary.

CLI Exit Codes & Manifest Schema

  • Exit codes: 0 (EXIT_OK, ok/empty), 1 (EXIT_ERROR), 2 (EXIT_USAGE), 3 (EXIT_LOGIN_TIMEOUT), 4 (EXIT_PARTIAL), 130 (interrupted / Ctrl-C).
  • manifest.json (schema_version = 1): schema_version, api_version, tool_version, created_at, provider, period_start, period_end, artifacts[] (artifact_id, name, path relative to manifest dir, sha256, bytes, provider, kind, period, valid, optional currency/error/observed_start/observed_end/meta), skipped[], errors[], timings_s.

Development Checks

make check

Metadata

Release files for statement-fetch 0.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for statement-fetch 0.7.1
File Size Uploaded Provenance Actions
statement_fetch-0.7.1.tar.gz 81.1 kB Without provenance Details for statement_fetch-0.7.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for statement-fetch 0.7.1
File Interpreter ABI Platform Actions
statement_fetch-0.7.1-py3-none-any.whl Python 3 none any Details for statement_fetch-0.7.1-py3-none-any.whl

Total release size: 139.5 kB

Release files / statement_fetch-0.7.1.tar.gz

Download URL statement_fetch-0.7.1.tar.gz
Size 81.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a3ea9185a82b744c92e827842fdf1fab390603450d9752f9ac1fae651787482b
BLAKE2b-256 checksum
How to use checksums
83cacf108bf3f5bec8fa9a977d2d266de678d36f5ae99d90e6d5b176a133c944
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / statement_fetch-0.7.1-py3-none-any.whl

Download URL statement_fetch-0.7.1-py3-none-any.whl
Size 58.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1442f329d2e86565f3950d25030133b904d8f881a9e1de4f36931a006c27a77b
BLAKE2b-256 checksum
How to use checksums
cf654eb5df0f4ad5dd6ac82a43fa413fd5a4bbab3f6784ab72d44d16e9c5fd51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for statement-fetch 0.7.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page