Skip to main content

BankFetch, download your own transactions via Enable Banking API

PyPI version Python Release

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.

Prerequisites

  • Python 3.13+
  • An Enable Banking account with a registered app and a linked bank account

Installation

uv tool install bankfetch

Or with pipx:

pipx install bankfetch

Setup

  1. Register at enablebanking.com/cp/applications and create a Production (Restricted) app (free for personal use on your own accounts).
  2. During app creation, set the redirect URL to https://localhost/auth_redirect. This must match exactly what the tool uses for the OAuth callback.
  3. Download the generated .pem private key.
  4. In the Control Panel, activate the app by linking at least one bank account ("Activate" button next to the app).
  5. Run bankfetch init to create a .env template 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
EB_ASPSP_NAME=<bank-name>                         # run `bankfetch aspsps` for available names
EB_ASPSP_COUNTRY=<CC>                             # two-letter country code, e.g. IT

Both .env and the .pem file must be owner-readable only (chmod 600). The tool refuses to start if they are world-readable.

Usage

List available banks:

bankfetch aspsps              # all banks
bankfetch aspsps --country IT # filter by country

Authenticate:

bankfetch auth                                        # uses EB_ASPSP_NAME / EB_ASPSP_COUNTRY from .env
bankfetch auth --bank "Banca Mediolanum" --country IT # override without editing .env

This 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

Options for fetch

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

CSV format

Date, Type, Description, Notes, Amount
  • Date - booking date, falls back to value date
  • Type - movement category
  • Description - merchant, counterparty, or reference text
  • Notes - free-text note left by the user in the banking app (parser-dependent)
  • Amount - signed amount (negative = debit)

Parsers

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.

Adding a parser

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.

Repository layout

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`, `aspsps` 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()

Development

git clone https://github.com/dpmungo/bankfetch
cd bankfetch
just install  # install dependencies including dev and pre-commit hooks
just test     # run all tests

A 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.

Metadata

Release files for bankfetch 0.2.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 bankfetch 0.2.1
File Size Uploaded
bankfetch-0.2.1.tar.gz 44.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bankfetch 0.2.1
File Interpreter ABI Platform
bankfetch-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 62.9 kB

Release files / bankfetch-0.2.1.tar.gz

Download URL bankfetch-0.2.1.tar.gz
Size 44.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6e7917cb1883086056945b393c7f1846fc69f603219d27df9d80eeb238dc86be
BLAKE2b-256 checksum
How to use checksums
44e61ea9c09c1c3433369a165e092be45ed59451df16c1717a3c7ada7649524f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 5, 2026.

Transparency log

Release files / bankfetch-0.2.1-py3-none-any.whl

Download URL bankfetch-0.2.1-py3-none-any.whl
Size 18.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e585eca424577d0224a13aa922feb77e1a4ec7f857431c80962e6f68a297a6ec
BLAKE2b-256 checksum
How to use checksums
62f3cb98f6e3a0503f96f545f8e2128bb77dc8e1393b1c0bb83c796423aef18f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 5, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

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