Using this library is quite simple.
Initial setup includes:
- Install the Library -
npm install intuit-cad
- require it to your applicaiton -
var IntuitCad = require('intuit-cad');
- instantiate the client with your credentials -
var client = new IntuitCad(authCreds)
Setting up configuration variables
There are two ways to set your configuration for your authentication for intuit
1. Environment variables - Recommended 2. Manually set variables
Both ways are handled the same way for the instantiation of the module, however, evironment variables are safer and more secure.
Setting up Authentication Object
NOTE: The recommended approach when using any library that requires passwords/tokens/private information to be used is to use environment variables. Since most written code is version controlled either by Git or some other system, one would not want to save passwords in configuration files because the passwords are then saved to that repository's history. These separate the need to maintain these passwords elsewhere.
In order for intuit to authenticate your SAML and OAuth API key we need to provide the OAuth server some information to verify we are able to use their CAD API. We do this by building an authentication object and passing it to the constructor of the module (ie -
var client = new IntuitCad(authCredentials);). This authentication object is built with this information:
var authCredentials =issuerId: processenvINTUIT_ISSUER_ID || 'myIssuerId'consumerKey:processenvINTUIT_CONSUMER_KEY || 'CONSUMERKEY'consumerSecret: processenvINTUIT_CONSUMER_SECRET || 'CONSUMER_SECRET'privateKeyPath: '/Users/britztopher/Documents/keys/comptest.key'customerId: '3';
BEST PRACTICE: Use environment variables here to eliminate saving passwords and sensitive information to my Git repository. (ie -
process.env.INTUIT_ISSUER_IDis used for environment variable
the SAML Identity Provider ID
the key that is given to your Intuit account when signing up
the secret which is given to your Intuit account when signing up
the path to your private key
this is a unique ID for each customer you plan on associating an Intuit account for. This should be unique for every instantiation of the module, so each OAuth key is different for each customer.
NOTE: do not use the same customerId for every request to CAD API. (ie - maybe use database primary key for customer)
Below is an image of what information is provided by Intuit when you sign up and create your application. This is found on your application's dashboard.
To set up environment variables on a Mac all you need to do is
export them in a terminal shell. For example, the command for doing so is:
if none of the environment variables are set it will take whatever you set it to. For instance, in the line:
consumerKey:process.env.INTUIT_CONSUMER_KEY || 'CONSUMERKEY'
it will use
CONSUMERKEY as the value of
There are a certain amount of options that are available. Right now, the only one is setting the logging level. To use options, you can pass an options object as a argument in the instatiation of the
logLevel option allows helps you debug your code by providing output from the
intuit-cad library. It has 3 levels:
...var options = logLevel: 'debug';var client = authCredentials options;
API Methods Available
this returns all the institutions that Intuit CAD system supports (around 19,000 of them)
this returns a specific institutions details
discoverAndAddAccounts(username, password, institution_id)
method for discovering and adding a customer's account to Intuit's database for you to query against
method for getting all the customer's accounts that was added in the
discoverAndAddAccounts method. This will use the
customerId you specified when authenticating to get that customer's accounts i.e -
returns all login accounts for a specific institution. The institutionLoginId is returned with a call to
getCustomerAccounts or any other method that returns account specific data
gets the details of a specific Account given the account ID
getAccountTransactions(accountId, txnStartDate, txnEndDate)
returns the transactions for a specific accound between a start and end date given in the format
updateInstitutionLogin(institutionalLoginId, username, newPassword)
method for updating the customer's password for a login account added by the
discoverAndAddAccounts method listed above
deletes an account from a customer's account list from Intuit's database
when used alone
or chained with
This call deletes the currently authenticated customer.
Coming Soon...Really soon
updates the account type of an account. This is only used when the category of an account gets categorized automatically to 'other'
Chaining Promise Methods
Since all of the methods return a promise we can chain them like the documentation for KrisKowal's Docs on Chaining Promises There are a couple of API calls that require data from a previous call, like
deleteAccount requires the
getCustomerAccount to be called initially because we need an
accountId for the account we want to delete. This is where chaining promises comes in handy. If I were to implement the above example, where I need to get the
accountId on a specific account I want to delete I need to first call:
var authCredentials =issuerId: processenvINTUIT_ISSUER_ID || 'nothing'consumerKey:processenvINTUIT_CONSUMER_KEY || 'CONSUMERKEY'consumerSecret: processenvINTUIT_CONSUMER_SECRET || 'CONSUMER_SECRET'privateKeyPath: '/Users/deputydog/Documents/projects/apps/comptest.key'customerId: '3';var IntuitCad = ;var client = authCredentials;clientclient;//using account i got from client.getAccounts()client;//Chainng function example.client;