The Mono Node library provides convenient access to the Mono API from applications written in server-side JavaScript.
For connecting customer accounts in the browser or an app, use the Mono Connect Widget.
For complete information about the API, head to the docs.
- Register on the Mono website and get your public and secret keys.
- Setup your Mono Connect Widget with your Mono public key.
Install the package with:
npm install mono-node --save
# or
yarn add mono-node
The package needs to be configured with your account's secretKey
, which is
available in the Mono Dashboard.
// import the module
const { Mono } = require("mono-node");
// set the secret key
const monoClient = new Mono({
secretKey: "test_sk_...",
});
// get your Mono Wallet balance
monoClient.user.walletBalance((err, results) => {
// Handle errors
if (err) {
console.log(err);
}
if (results){
console.log(results);
};
});
- Wallet Balance
- Get Account ID from Auth Code
- Unlink Account
- Account Information
- Account Statement
- Poll Account Statement PDF
- Transactions
- Credits
- Debits
- Income Information
- Identity
- Sync Data
- Re-auth Code
- Institutions
Once an instance of the client has been created you use the following methods:
This resource allows you to check the available balance in your Mono wallet
monoClient.user.walletBalance(callback);
This resource returns the account id (that identifies the authenticated account) after successful enrolment on the Mono Connect Widget.
monoClient.auth.getAccountId({code: String}, callback);
This resource provides your customers with the option to unlink their financial account(s)
monoClient.account.unlinkAccount({accountId: String}, callback);
This resource returns the account details with the financial institution.
monoClient.account.getAccountInformation({accountId: String}, callback);
This resource returns the bank statement of the connected financial account in JSON.
You can query 1-12 months bank statement in one single call.
monoClient.account.getAccountStatement({accountId: String, output: 'json'}, callback);
This resource returns the bank statement of the connected financial account in PDF.
You can query 1-12 months bank statement in one single call.
monoClient.account.getAccountStatement({accountId: String, output: 'pdf'}, callback);
With this resource, you set the output as PDF, and you can use this endpoint to poll the status
monoClient.account.pollPdfAccountStatementStatus({accountId: String, jobId: Striing}, callback);
This resource returns the known transactions on the account.
monoClient.account.getAccountTransactions({accountId: String, type: 'credit'}, callback);
This resource returns the historical credits on the account
monoClient.account.getCustomerCredits({accountId: String}, callback);
This resource returns the historical debits on the account
monoClient.account.getCustomerDebits({accountId: String}, callback);
This resource will return income information on the account.
monoClient.account.getIncome({accountId: String}, callback);
This resource returns a high level overview of an account identity data.
monoClient.account.getIdentity({accountId: String}, callback);
This resource attempts to Sync data manually.
monoClient.account.syncDataManually({accountId: String}, callback);
This resource returns a Re-auth code which is a mono generated code for the account you want to re-authenticate,
monoClient.account.reauthCode({accountId: String}, callback);
This resource returns the available institutions on Mono
monoClient.misc.institutions(callback);
All requests have callbacks of the following form:
function callback(err, results) {
// Handle errors
if (err) {
console.log(err);
}
if (results){
console.log(results);
};
}
The err
argument passed to the callback is a Mono API error.
function callback(err, results) {
if (err != null) {
console.log(err)
}
}
Exchange an auth code
from Mono Connect Widget for an accountId
and then retrive account data:
Note: If the meta data_status
is still in the processing stage, you have to wait before calling the APIs below e.g Statement, Transaction, Income and Identity Endpoints. Some banks are faster than others, so it may be available instantly after authorization and some banks might take a few seconds or minutes.
// code from Mono Connect Widget
const authCode = 'RANDOM_CODE'
monoClient.auth.getAccountId({code: authCode}, (err, results) => {
const accountId = results.id
monoClient.account.getAccountInformation({accountId: accountId}, (err, results) => {
console.log(results.account)
if(results.meta.data_status == 'AVAILABLE'){
console.log('Account data ready for use.')
}
});
});
Get account transactions for the last thirty days:
const now = moment();
const today = now.format('DD-MM-YYYY');
const thirtyDaysAgo = now.subtract(30, 'days').format('DD-MM-YYYY');
monoClient.account.getAccountTransactions({accountId: String, start: today, end: thirtyDaysAgo, paginate: false}, (err, results) => {
console.log(`You have ${results.data.length} transactions from the last thirty days.`);
});
Get income for an account:
Note: This is a number estimated by Mono. It is not nesecarrily 100% correct, however, a confidence interval is provided to show the estimations accuracy.
monoClient.account.getIncome({accountId: String}, (err, results) => {
console.log(`Your ${results.type} is ${results.amount}. You work at ${results.employer}`);
});
Get an identity for an account:
Note: Not all banks return identity information. See Coverage
monoClient.account.getIdentity({accountId: String}, (err, results) => {
console.log(`Your ${results.type} is ${results.amount}. You work at ${results.employer}`);
});
Manual data sync for an account:
Note: This may require some users to re-authorize their bank account with Mono. See Re-authorization
monoClient.account.syncDataManually({accountId: String}, (err, results) => {
console.log(`Status: ${results.status}`);
});
Get re-auth code for an account:
Note: Please note that this Re-auth code/token expires in 10 minutes. You will need to pass the re-auth code to a Mono Connect Widget to complete verification.
monoClient.account.reauthCode({accountId: String}, (err, results) => {
console.log(results.token);
});
Unlink a bank account:
It is strongly recommend to implement this feature to build trust with your users and allow them to have complete control of their data. See Docs
monoClient.account.unlinkAccount({accountId: String}, (err, results) => {
console.log(results.message);
});
If you're having general trouble with Mono Node.js or your Mono integration, please reach out to us at hi@mono.co or come chat with us on Slack. We're proud of our level of service, and we're more than happy to help you out with your integration to Mono.
If you would like to contribute to the Mono Node.js Library, please make sure to read our contributor guidelines.
MIT for more information.