This is a hopefully simple CLI tool that fetches bank account transactions via Enable Banking and exports them to CSV. Enable Banking acts as the licensed AISP intermediary, so you don't need an eIDAS certificate or TPP registration of your own.
Built primarily for accessing transactions in my Banca Mediolanum account, but you can implement your own parser to support other banks in a hopefully straightforward way.
- Python 3.13+
- An Enable Banking account with a registered app and a linked bank account
uv tool install bankfetchOr with pipx:
pipx install bankfetch- Register at enablebanking.com/cp/applications and create a Production (Restricted) app (free for personal use on your own accounts).
- During app creation, set the redirect URL to
https://localhost/auth_redirect. This must match exactly what the tool uses for the OAuth callback. - Download the generated
.pemprivate key. - In the Control Panel, activate the app by linking your bank account ("Activate" button next to the app).
- Run
bankfetch initto create a.envtemplate in the current directory, then fill in the required values:
EB_APP_ID=<your-app-uuid>
EB_PRIVATE_KEY_PATH=<path-to-key.pem>
EB_REDIRECT_URL=https://localhost/auth_redirect # default, must match Control Panel
EB_SESSION_FILE=.session.json # default
EB_ACCESS_DAYS=30 # how many days ahead the bank access grant is valid
Both .env and the .pem file must be owner-readable only (chmod 600). The tool refuses to start if they are world-readable.
Authenticate:
bankfetch authThis opens a browser to the bank's login page. After completing authentication, the browser redirects to https://localhost/auth_redirect (which will not load — that's expected). Copy the full URL from the address bar and paste it into the terminal. The session is saved to .session.json and reused on subsequent calls. Re-authentication is triggered automatically when the session expires.
Fetch transactions to CSV:
bankfetch fetch --from 2024-01-01
bankfetch fetch --from 2024-01-01 --output my-transactions.csv
bankfetch fetch --from 2024-01-01 --to 2024-12-31 --account IT60X0542811101000000123456
bankfetch fetch --help| Option | Default | Description |
|---|---|---|
--from YYYY-MM-DD |
none | Start date (inclusive) |
--to YYYY-MM-DD |
none | End date (inclusive) |
--output FILE |
transactions.csv |
Output path |
--account IBAN|UID |
first available | Target account |
--parser NAME |
generic |
Transaction parser to use |
Date, Type, Description, Notes, Amount
Date- booking date, falls back to value dateType- movement categoryDescription- merchant, counterparty, or reference textNotes- free-text note left by the user in the banking app (parser-dependent)Amount- signed amount (negative = debit)
Parsers translate raw Enable Banking transaction objects into the CSV columns above. Selected with --parser NAME.
| Name | Description |
|---|---|
generic |
Default. Works with any bank. Uses bank_transaction_code, creditor/debtor name, and the first remittance segment. |
mediolanum |
Banca Mediolanum. Parses the bank's remittance_information segments in detail to extract movement category, merchant/counterparty, and user notes. |
Drop a .py file in ~/.config/bankfetch/parsers/ (override with $BANKFETCH_PARSERS_DIR). It is loaded automatically on every run.
# ~/.config/bankfetch/parsers/mybank.py
from bankfetch.parsers import BaseParser, ParsedTransaction, register
@register("mybank")
class MyBankParser(BaseParser):
def parse(self, txn: dict) -> ParsedTransaction:
...Then use it with bankfetch fetch --parser mybank. Run bankfetch parsers to see all available parsers.
If your parser could be useful to others, feel free to fork the repo, add it under src/bankfetch/parsers/, and open a pull request — contributions are welcome.
src/bankfetch/
├── config.py Config dataclass; loads .env; enforces file permissions
├── auth.py RS256 JWT signing; OAuth2 redirect flow; SessionStore
├── client.py EnableBankingClient: account details + paginated transactions
├── export.py to_csv(): runs a parser over transactions and writes CSV
├── cli.py Typer CLI — `init`, `auth`, `fetch`, `parsers` subcommands
└── parsers/
├── __init__.py BaseParser ABC; @register decorator; auto-discovery
├── generic.py GenericParser — works with any bank
└── mediolanum.py MediolanumParser — Banca Mediolanum remittance parsing
tests/
├── conftest.py Shared fixtures (RSA key generation, sample transactions)
├── test_auth.py JWT generation, redirect URL validation, session flow
├── test_client.py Account and transaction fetch, pagination
└── test_export.py GenericParser, _variazione, to_csv()
git clone https://github.com/dpmungo/bankfetch
cd bankfetch
just install # install dependencies including dev and pre-commit hooks
just test # run all testsA Justfile is included with shortcuts for all common tasks (just auth, just fetch, etc.). Run just or just --list to see everything available.
Linting, formatting, and type-checking run automatically via pre-commit on every commit.