flanks v0.1.1
flanks-node
Node.js client for Flanks API.
Install
$ npm install flanks
Getting started
This module enables Node.js developers to easily access all Flanks API endpoints.
First, include the flanks
module in your desired .js
files:
const flanks = require('flanks');
Then, you can start using the supported endpoints. This module is using endpoints from a stateful sandbox environment.
You can find the complete API Documentation here.
Token overview
Most API requests interact with a credentials_token
or a set of credentials
(map of key-value pairs) associated with a financial institution. A single end-user of your application might have accounts at different financial institutions.
Credit and depository accounts may also have transactions associated with them.
That credentials_token
or credentials
uniquely identify the account. You can use the access_token
along with your OAuth Token
to access products available for an account and make changes to it over time.
Important: remember to pass your OAUTH_TOKEN
as an environment variable when calling your script.
$ OAUTH_TOKEN=<YOUR_OAUTH_TOKEN> node script.js
Accessing data
Once you create a credentials_token
, you can then access data—such as transaction data, account information and routing numbers—using our API endpoints. You access data using the credentials_token
, which is specific to your API keys and cannot be shared or used by any other API keys. By default, a credentials_token
never expires, but it can rotate.
Creating credentials
Now that you have API keys and know the basics of the Flanks API, it is time to integrate with flank's clients, which will handle credential validation, multi-factor authentication, and error handling for each institution that we support.
Clients allow interaction with the Flanks system in an easier and faster way. We currently have different clients that are integrated with the main important market languages. In our clients, previous validations are incorporated to save calls to the system and speed up the interaction with it.
Credentials can be created as follows:
flanks.createCredentials({
username: 'username',
password: 'password',
bank: 'bank',
})
.then(response => {
console.log(response.data);
})
.catch(err => {
console.error(err);
});
The following is a successful response:
{
"credentials_token": "<YOUR_CREDENTIALS_TOKEN>",
"message": "Credentials created successfully"
}
Deleting credentials
Similarly, to delete existing credentials, simply use its associated credentials_token
:
flanks.deleteCredentials('<YOUR_CREDENTIALS_TOKEN>')
.then(response => {
console.log(response);
})
.catch(err => {
console.error(err);
});
// async version
async function foo() {
try {
const response = await flanks.deleteCredentials('<YOUR_CREDENTIALS_TOKEN>');
console.log(response.data);
} catch (err) {
console.error(err);
}
}
Pulling financial data
Once you have a credentials_token
, you can use it to access financial information without need to input passwords periodically:
flanks.getAccountData('<YOUR_CREDENTIALS_TOKEN>')
.then(response => {
console.log(response.data);
})
.catch(err => {
console.error(err);
});
A successful response has the following schema:
{
"account": {
"alias": "string",
"amount": {
"value": null,
"currency": "string"
},
"availability": "string",
"bank": "string",
"description": "string",
"iban": "string",
"isOwner": true,
"numOwners": null,
"owner": "string"
},
"amount": null,
"balance": null,
"bank": "string",
"cardNumber": "string",
"category": "string",
"currency": "string",
"dateOperation": "yyyy-mm-dd",
"dateValue": "yyyy-mm-dd",
"description": "string",
"expense": true,
"id": "string",
"productDescription": "string",
"service": "string",
"transfer": {
"beneficiary": "string",
"ibanBeneficiary": "string",
"ibanOrdenant": "string",
"ordenant": "string"
}
}
Pulling personal data
Flanks allows you to retrieve all personal information from a bank account:
flanks.getAuth('<YOUR_CREDENTIALS_TOKEN>')
.then(response => {
console.log(response.data);
})
.catch(err => {
console.error(err);
});
Pulling card information
You can get information about the cards associated to your bank account.
flanks.getCards('<YOUR_CREDENTIALS_TOKEN>')
.then(response => {
console.log(response.data);
})
.catch(err => {
console.error(err);
});
Pulling card transactions
You can also pull the transactions associated with your cards.
flanks.getCardTransactions('<YOUR_CREDENTIALS_TOKEN>')
.then(response => {
console.log(response.data);
})
.catch(err => {
console.error(err);
});
Uploading files
Flanks provides several endpoints to help business banking users with file handling and management.
You can upload a file to your business banking account.
flanks.uploadFile('<YOUR_CREDENTIALS_TOKEN>', '<PATH_TO_FILE>', '<FILE_TYPE>')
.then(response => {
console.log(response.data);
})
.catch(err => {
console.error(err);
});
Check the API docs linked above to find out about the supported file types and extensions.
Using ES2017 async/await
You can also use the new async/await
keywords introduced in ECMAScript 2017. For example, inside an async
function, you could pull data like this:
async function foo() {
try {
const response = await flanks.getAccountData('<YOUR_CREDENTIALS_TOKEN>');
console.log(response.data);
} catch (err) {
console.error(err);
}
}