AI and data
statement-extract
Turn PDF bank statements into exact, reconciled transaction data with Claude, with an eval suite that measures it.
- GitHub ↗
- MIT
Turn a PDF bank statement into transaction data you can post to a ledger, and check every figure against the statement's own arithmetic before you trust it.
statement-extract march.pdf --out tx.jsonQuick start
Requires Node 24.2 or later and an Anthropic API key.
git clone https://github.com/aranshayan/statement-extract.git && cd statement-extract
npm ci
npm run build
export ANTHROPIC_API_KEY=sk-ant-...
node dist/cli.js eval/fixtures/03-de-soll-haben.pdf --out tx.json
npm link puts statement-extract on your PATH.
Usage: statement-extract <statement.pdf> [options]
-o, --out <file> Write JSON here instead of stdout
-m, --model <id> Claude model (default: $STATEMENT_EXTRACT_MODEL or claude-opus-5-5)
-e, --effort <level> low | medium | high | xhigh | max (default: medium)
--max-tokens <n> Reply token limit (default: 64000)
--no-fallback Do not let the API retry a refused request on another model
Exit codes: 0 reconciled, 2 extracted but failed validation, 1 error.
Output, shortened:
{
"ok": true,
"statement": {
"currency": "EUR",
"period_start": "2026-02-01",
"period_end": "2026-02-28",
"opening_balance": "3507.90",
"closing_balance": "4890.97",
"transactions": [
{
"date": "2026-02-01",
"description": "Lastschrift Mobilfunk Nordnetz",
"amount": "-46.41",
"currency": "EUR",
"balance": "3461.49"
}
]
},
"issues": [],
"attempts": 1,
"models": ["claude-opus-5-5"],
"usage": { "input_tokens": 0, "output_tokens": 0, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 0 },
"cost_usd": 0
}
(usage and cost_usd hold real numbers on a real run.)
As a library
import { readFile } from "node:fs/promises";
import { extractStatement } from "statement-extract";
const result = await extractStatement(await readFile("march.pdf"), {
model: "claude-opus-5-5",
effort: "medium",
});
if (!result.ok) throw new Error(result.issues.map((i) => i.message).join("\n"));
for (const tx of result.statement!.transactions) {
// tx.amount is a string; use a decimal library or integer minor units, never parseFloat.
}
validateStatement and parseStatement are exported too, if you only want
the checks for data that came from somewhere else.