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

Plugin API (API_VERSION = 1)

Third-party providers and sinks 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"
  • Reference provider: src/statement_fetch/providers/example_bank.py
  • Reference sink: src/statement_fetch/sinks/directory.py
  • Versioning: the entry-point group names (statement_fetch.providers, statement_fetch.sinks) 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.5.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.5.1
File Size Uploaded Provenance Actions
statement_fetch-0.5.1.tar.gz 65.1 kB Without provenance Details for statement_fetch-0.5.1.tar.gz

Built distribution (wheel)

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

Total release size: 111.1 kB

Release files / statement_fetch-0.5.1.tar.gz

Download URL statement_fetch-0.5.1.tar.gz
Size 65.1 kB
Tags Source
SHA-256 checksum
How to use checksums
770034cf0537e55f3dc9327b547b2958a0954bd2a1ad7672c6995463de645fe5
BLAKE2b-256 checksum
How to use checksums
f95200fb9ffa0792ac7ef8f04011147c96ad2b1e6864fbf36124b01d841a2fcc
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.5.1-py3-none-any.whl

Download URL statement_fetch-0.5.1-py3-none-any.whl
Size 46.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5aee6831eb15e4b5b36ab314a5c90efacb0fa7559255e689cd460ec47735b496
BLAKE2b-256 checksum
How to use checksums
bcc32d38b8a8a9a40527e71bd1ccf046e61bea33eeb61a84f9422729f01f927a
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.5.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