A C# library plus whitepaper and specification for pulling your own bank transactions through the Enable Banking open banking API into a local SQLite database, so a self-hosted app can show them without manual CSV exports. Written for a private Nordea Denmark customer, usable with any bank Enable Banking supports.
It is built to be deployed for real: an encrypted database, a login with a second factor, phones that sign every request with a key in their secure hardware, and answers sealed to the phone so that a Cloudflare Tunnel carries ciphertext only.
The library does all the hard parts. Your app registers it, provides
three endpoints (connect, callback, refresh) and reads from IBankSync.
Consent, JWTs, the PSD2 four-calls-per-day quota, history backfill,
deduplication and storage are inside.
builder.Services.AddBankSync(builder.Configuration);
// …
var accounts = await bank.GetAccountsAsync();
var page = await bank.GetTransactionsAsync(new TransactionQuery { AccountId = accounts[0].Id, Take = 50 });- Why Enable Banking
- What is in this repository
- Who reads what
- Prerequisites
- Security at a glance
- Deploying
- Quick start: the library
- Quick start: the documentation
- Building and testing
- Publishing on GitLab Pages or GitHub
- Facts the design rests on
- Confirmed against the sandbox
- Still to confirm
- Next steps
- Security notes for this repository
- Contributing and conventions
- Status
- Licence
Nordea exposes its PSD2 account API only to licensed third-party providers with an eIDAS certificate, which a private person cannot obtain. Enable Banking (Helsinki, licensed account information service provider) offers a free restricted production mode: you link your own Nordea accounts in their control panel, your app authenticates with a private key, and you approve access once with MitID. The app then receives balances and transactions as JSON for up to 180 days per consent.
It is not the only way in theory, but it is the only route that is free, contract-free, compliant with Nordea's terms and open to a private person:
| Alternative | Why not |
|---|---|
| Nordea's own developer portal | Production access needs a PSD2 licence and an eIDAS certificate |
| Commercial aggregators (Tink, Plaid, TrueLayer, Mastercard) | Contracts, KYB checks and monthly minimums aimed at companies |
| GoCardless Bank Account Data (ex-Nordigen) | Closed to new sign-ups and being wound down |
| No-code sync products | Data leaves your server, subscription cost |
| Manual CSV export | The status quo; planned as a fallback import |
| Screen-scraping with your MitID | Breaks Nordea's terms and breaks on every UI change |
The full comparison is in the whitepaper.
.
├── README.md, LICENSE (MIT)
├── BankSync.slnx # solution: library, device auth, tests, sample apps
├── src/
│ ├── BankSync/ # the library: Enable Banking, quota, backfill, encrypted SQLite (NuGet "BankSync")
│ ├── BankSync.DeviceAuth/ # phone side: signed requests, sealed answers, pairing client (no dependencies)
│ └── BankSync.Tests/ # xUnit tests, an in-process fake Enable Banking API, the real host in memory
├── samples/
│ ├── BankSync.DemoApp/ # the host: web pages, login + one-time code, pairing, phone API
│ └── BankSync.PhoneSimulator/ # stands in for the Android app to test a deployment
├── deploy/ # server + Cloudflare Tunnel: compose file, entrypoint, deploy script, Dockerfile
├── docs/ # the documentation site (MkDocs + Material)
│ ├── whitepaper.md, developer-spec.md, library.md, api-reference.md
│ ├── android-api.md # pairing, signed requests, sealed answers, for the Android developer
│ ├── deployment.md # server + Cloudflare Tunnel, step by step
│ ├── security.md # what is protected, what each party sees, what is not built
│ ├── setup-checklist.md # owner's steps at Enable Banking
│ └── privacy-and-risks.md # the short version
├── Serve-Docs.ps1 # serves the documentation on localhost (no GitLab needed)
├── mkdocs.yml, .gitlab-ci.yml # docs site and GitLab pipeline (tests + Pages)
└── .github/workflows/ci.yml # GitHub Actions: build, test, pack on tag, docs to GitHub Pages
| Document | What it covers |
|---|---|
| Whitepaper | Problem, requirements, seven options compared, PSD2 terms in plain language, who is responsible for what, the consent-and-sync flow as a sequence diagram, a constraints table with design consequences, Nordea DK specifics, costs, phased roadmap, open points, references |
| Developer specification | Scope, goals, technology stack, architecture, configuration keys, JWT and client rules, consent state machine and routes, sync engine with the quota model and history backfill, data model, UI pages, security requirements, Docker deployment, tests, acceptance criteria |
| Library guide | Registering BankSync, configuration keys, the three endpoints the app provides, reading data, consent states, diagnostics, error behaviour, sandbox walkthrough, roadmap |
| Android API | Pairing a phone, the signed request token, the endpoints, opening the sealed answers, Keystore guidance, error handling, a sketch of the two classes the app supplies |
| Deployment | server and Cloudflare Tunnel step by step: secrets, tunnel, files, deploy script, checks, first consent, pairing, everyday operation, troubleshooting |
| Security | Threats, what each party can see, every control that is built, every gap, how each claim was checked |
| API reference | The Enable Banking endpoints the library uses with JSON examples, PSU headers, balance types, pagination, error codes, sandbox notes |
| Owner setup checklist | Account, key pair, production app registration, linking own accounts, network decisions, hand-over to the developer, first consent, renewal, revocation |
| Privacy and risks | Data flow, what the app can and cannot do, risk table with mitigations, legal notes, owner's checklist |
| Reader | Start here |
|---|---|
| Owner (decides, registers the Enable Banking app, gives consent with MitID) | Whitepaper, then setup checklist |
| Android developer | Android API, then src/BankSync.DeviceAuth and samples/BankSync.PhoneSimulator |
| App developer (builds the UI and the Docker image) | Library guide, then developer specification sections 10 to 12, samples/ |
| Library contributor | Developer specification sections 5 to 9, API reference, src/ |
| Owner deploying it | Deployment, then Security |
| Everyone | Privacy and risks |
| Purpose | Needs |
|---|---|
| Reading the documents | Nothing. Plain Markdown with Mermaid diagrams, which GitLab and GitHub render. |
| Viewing the rendered site locally | PowerShell 5.1 or 7, Python 3.9+ on PATH. Serve-Docs.ps1 installs the rest into .venv. |
| Building the library, tests and demo app | .NET SDK 10.0 |
| Publishing the docs with GitLab Pages | A GitLab server with Pages enabled and a runner using the Docker executor |
| Running an app on the library | Docker on the owner's server, a reverse proxy with TLS, an Enable Banking account |
| Layer | What it does |
|---|---|
| Database | The whole file is encrypted (SQLCipher, AES-256); the key is kept apart from the data |
| Web pages | Password (PBKDF2, 600k iterations) plus a one-time code, lockout, CSRF tokens, strict headers |
| Phone | A key in the Android Keystore signs a token for each request: valid for one request, bound to its method, path and query |
| Phone answers | Encrypted to a key only the phone holds, so Cloudflare carries ciphertext |
| Tunnel | Only /api/, /callback and /healthz are reachable through it; the proxy is trusted by exact address, never a subnet |
| Start-up | In server mode the app refuses to start without a login, a second factor and an encrypted database |
The honest list of what is not built (the Android app itself, hardware keys before Android 12, plain http at home if you choose it, Cloudflare reading request paths) is in Security. 148 automated tests cover the above, and a published build was run end to end on a real socket.
Target: a server with Docker, reachable by the phone app through a Cloudflare Tunnel.
.\deploy\Deploy-ToServer.ps1 -ServerPath \\server\docker\banksync -BaseUrl http://<server-address>:8082 -ServerHost <server-address> -ServerUser <account on the server>The full walk-through (secrets, Cloudflare, files on the server, first consent, pairing a phone, checks) is
docs/deployment.md. Until the Android app exists, samples/BankSync.PhoneSimulator proves the
whole path, tunnel included.
git clone <repository-url> banksync
cd banksync
dotnet test BankSync.slnxThen in your own ASP.NET Core project:
dotnet add reference path/to/src/BankSync/BankSync.csproj # or: dotnet add package BankSync (once published)builder.Services.AddBankSync(o =>
{
o.ApplicationId = "<from the Enable Banking control panel>";
o.PrivateKeyPath = "/run/secrets/eb_private_key";
o.RedirectUrl = "https://your.host/callback";
o.DatabasePath = "/data/banksync.db";
});The library guide has the three endpoints to add and
every read method. samples/BankSync.DemoApp is a runnable version:
cd samples/BankSync.DemoApp
dotnet user-secrets set BankSync:ApplicationId <sandbox app id>
dotnet user-secrets set BankSync:PrivateKeyPath C:\Users\<you>\secrets\sandbox.pem
dotnet user-secrets set BankSync:DatabasePath C:\Users\<you>\banksync-data\banksync.db
dotnet runSettings, key and database all live outside the repository, so nothing personal can be committed by accident. In Development, with no login configured, the host has none: run it on localhost only. Outside Development it refuses to start without one. Details in samples/BankSync.DemoApp/README.md.
.\Serve-Docs.ps1The browser opens at http://127.0.0.1:8000/ with the whitepaper site.
Serve-Docs.ps1 creates a Python virtual environment in
.venv (git-ignored), installs mkdocs-material on first run, starts
mkdocs serve with live reload and opens the browser.
.\Serve-Docs.ps1 # serve on http://127.0.0.1:8000/ and open the browser
.\Serve-Docs.ps1 -Port 8080 # another port
.\Serve-Docs.ps1 -NoBrowser # serve only
.\Serve-Docs.ps1 -Build # write a static copy to .\site\ (open site\index.html)If script execution is blocked:
powershell -ExecutionPolicy Bypass -File .\Serve-Docs.ps1Alternatives: docker run --rm -it -p 8000:8000 -v "${PWD}:/docs" squidfunk/mkdocs-material serve -a 0.0.0.0:8000,
or pip install mkdocs-material followed by mkdocs serve, or simply open
the .md files in docs/ in GitLab, GitHub or VS Code.
dotnet build BankSync.slnx
dotnet test BankSync.slnx
dotnet pack src/BankSync/BankSync.csproj -c Release -o outThe tests use an in-process fake of the Enable Banking API and a fake clock. They cover the JWT, the consent flow, quota enforcement and day rollover, backfill resumption across days, PSU header handling, deduplication, pending-to-booked replacement, pagination, expiry and listener notifications. No network access is needed.
GitLab: push, enable Pages, make a Docker-executor runner available.
.gitlab-ci.yml runs the .NET tests, builds the site in
strict mode and publishes public/ on the default branch. The site
appears at https://<namespace>.<pages-domain>/<project>/.
GitHub: .github/workflows/ci.yml builds and
tests on every push and pull request, builds the docs in strict mode, and
publishes them to GitHub Pages on every push to main. One-time setup in
the repository: Settings → Pages → Build and deployment → Source:
GitHub Actions. The site then appears at
https://<user>.github.io/<repository>/. A v* tag additionally packs a
NuGet package; publishing to nuget.org needs a NUGET_API_KEY secret and
uncommenting one line in the workflow.
| Fact | Consequence, implemented in the library |
|---|---|
| Consent is valid for at most 180 days (Nordea DK) | ConsentStatus.NeedsRenewal 14 days before expiry; renewal keeps account identity and user data |
| Unattended fetches are limited to 4 per account per day | Fixed slots, a per-call counter, no retry loops on HTTP 429; manual refresh sends PSU headers and is exempt |
| Full history is only available for about an hour after consent, afterwards roughly 90 days | Backfill is queued the moment consent completes and reuses the owner's PSU headers for 55 minutes |
| Restricted production returns only accounts linked in the control panel | ConsentStatus.AccountCount == 0 plus a logged hint |
| Enable Banking does not store account data | SQLite on your server is the only persistent copy, so protect it and back it up encrypted |
| Read-only: no payment initiation without a PISP licence | The library has no payment calls at all |
A full consent, initial load and refresh ran against the real sandbox with three invented accounts and about 400 transactions. What the real responses showed:
| Question | Answer |
|---|---|
| Which reference field does Nordea fill? | entry_reference, a UUID. transaction_id is absent. The library keys on the entry reference. |
| Is the amount sign reliable? | Amounts arrive as positive strings with credit_debit_indicator CRDT or DBIT. The library applies the sign: debits negative, credits positive. |
| Counterparty names? | Absent in the sandbox data. The merchant is inside the remittance text, so apps should show the text when the counterparty is empty. |
| Bank transaction code? | Empty or only a short description such as BGS. The library stores the description when there is no code. |
| Balance types? | ITBD booked, ITAV available, VALU value-dated. There is no CLBD. Use Booked() and Available() on the balance list instead of testing for a type. |
| Running balance per transaction? | balance_after_transaction is absent. |
| Joint accounts? | The account name holds both owners separated by a semicolon. |
| Text encoding? | Danish characters arrive and are stored correctly. |
These need the production API or a deliberately forced error:
- The exact error code when a session has expired. The library matches any
4xx whose code contains
EXPIREDorSESSION_CLOSED. - Whether each page of a paginated fetch counts separately against the daily quota. The library assumes yes.
- Whether production Nordea data differs from the sandbox, for example whether real transactions carry counterparty names and transaction codes.
- The column names of Nordea's CSV export, for the planned fallback importer.
- Push to GitLab (or GitHub) and let the pipeline run.
- Owner: work through the setup checklist and answer the four open points at the end of the whitepaper.
- Developer: run the demo app against the Enable Banking sandbox, then
build the UI described in the developer specification on top of
IBankSync. - Owner: install the production private key on the server yourself; hand the developer only the application id.
- Never commit private keys, certificates,
.envfiles or database files..gitignoreblocks*.pem,*.key,*.crt,*.p12,*.pfx,.env*(except.env.example),*.dbandbanksync.key. - The Enable Banking application ID is not secret, but keep it out of public issues together with any hostname.
- Anonymise any real CSV export or API response before adding it to the tests or samples.
- If a key is ever committed by accident, revoke it in the Enable Banking control panel and register a new certificate; rewriting history is not enough.
- Default branch
main; work on feature branches and merge via merge or pull requests so the tests and the docs build run first. - Library code: nullable enabled, warnings clean, no network in tests. Public API changes need a note in the library guide.
- Documents are Markdown with Mermaid diagrams;
mkdocs build --strictmust pass. - Line endings are LF (see
.gitattributes);Serve-Docs.ps1is CRLF. - Commit messages: imperative subject line, body explaining why.
| Date | Change |
|---|---|
| 2026-10-02 | First version of all documents, Pages pipeline and local serve script. |
| 2026-10-02 | BankSync library 0.1.0 with tests and demo app; MIT licence; GitHub Actions workflow. |
| 2026-10-05 | Encrypted database, second factor, phone pairing with signed requests and sealed answers, server and Cloudflare Tunnel deployment, phone client and simulator. |
| 2026-10-04 | First run against the Enable Banking sandbox. Fixed the scheduler missing the initial load after a slot had fired, config slots doubling the defaults, the fresh-install Connect button, booked-balance detection for Nordea. |
MIT, see LICENSE. The Enable Banking API, its documentation and sample code are subject to Enable Banking's own terms.