Sync bank account transactions to MongoDB via the Enable Banking API.
Built for Testausserveri to display our association's bank account activity in real-time in the members' area:
-
Install dependencies:
npm install
-
Create a
config.jsonwith your Enable Banking credentials:{ "keyPath": "your-app-id.pem", "applicationId": "your-app-id", "redirectUrl": "https://your-redirect-url/auth_redirect", "psuIpAddress": "10.10.10.10", "psuUserAgent": "Some useful name", "mongoUri": "mongodb://localhost:27017", "mongoDbName": "testausbanking" } -
Place your Enable Banking private key (
.pemfile) in the project root.
Connect a bank account first:
npm run authThis will:
- Let you choose a bank
- Open an authorization URL in your browser
- After authorizing, paste the redirect URL back
- Select which account to use
Once authenticated, fetch transactions:
npm start This will:
- Fetch account balance
- Fetch all transactions from the past year (with pagination)
- Upsert to MongoDB
-v, --verbose Enable verbose output
--auth Run authentication flow
-h, --help Display help
Alternatively you can set config parameters mongoUri and mongoDbName using environment variables:
MONGODB_URIMONGODB_DB
Collections used:
bank_balance- Account balance snapshotsbank_transactions- Transaction history (upserted byentry_reference)
