import { BunqAccount, BunqPayment } from '@apiclient.xyz/bunq'; async function main() { // Initialize bunq client const bunq = new BunqAccount({ apiKey: 'your-api-key', deviceName: 'My App', environment: 'PRODUCTION' // or 'SANDBOX' }); try { // Initialize the client (handles installation, device registration, session) await bunq.init(); console.log('Connected to bunq!'); // Get all monetary accounts const accounts = await bunq.getAccounts(); console.log(`Found ${accounts.length} accounts:`); for (const account of accounts) { console.log(`- ${account.description}: ${account.balance.currency} ${account.balance.value}`); } // Get transactions for the first account const firstAccount = accounts[0]; const transactions = await firstAccount.getTransactions(); console.log(`\nRecent transactions for ${firstAccount.description}:`); for (const transaction of transactions.slice(0, 5)) { console.log(`- ${transaction.amount.value} ${transaction.amount.currency}: ${transaction.description}`); } // Create a payment (example) const payment = await BunqPayment.builder(bunq, firstAccount) .amount('10.00', 'EUR') .toIban('NL91ABNA0417164300', 'John Doe') .description('Payment for coffee') .create(); console.log(`\nPayment created successfully!`); } catch (error) { console.error('Error:', error.message); } finally { // Always clean up when done await bunq.stop(); } } // Run the example main().catch(console.error);