plaid-node-legacy
A node.js client library for the legacy version of the Plaid API.
This module was forked from plaid-node
version 1.2.0
.
Table of Contents
Install
$ npm install plaid-legacy
Getting started
The module supports all Plaid API endpoints. For complete information about the API, head to the docs.
Public Endpoints
Public endpoints (category and institution information) require no authentication and can be accessed as follows:
var plaid = ; plaid;plaid; plaid;plaid; plaid;plaid; plaid;plaid;
plaid_env
dictates which Plaid API environment you will access. Values are:
plaid.environments.tartan
- use for integration development and testing, creates users on https://tartan.plaid.complaid.environments.production
- production use, creates users on https://api.plaid.com
Environments are exported from the module, i.e.:
var plaid = ; console;
Authenticated Endpoints
Authenticated endpoints require a valid client_id
and secret
to access. You can use the sandbox
client_id and secret for testing (test_id
and test_secret
).
All authenticated endpoints are accessible from an instance of a Plaid Client
:
var plaid = ; var plaidClient = client_id secret plaid_env;
The plaid_env
parameter dictates which Plaid API environment you will access. Values are:
plaid.environments.tartan
- use for integration development and testing, creates users on https://tartan.plaid.complaid.environments.production
- production use, creates users on https://api.plaid.com
Once an instance of the client has been created you use the following methods:
var plaid = ; // Initialize clientvar plaidClient = client_id secret plaid_env; // addAuthUser(String, Object, Object?, Function)plaidClient;// stepAuthUser(String, String, Object?, Function)plaidClient;// getAuthUser(String, Object?, Function)plaidClient;// patchAuthUser(String, Object, Object? Function)plaidClient;// deleteAuthUser(String, Object?, Function)plaidClient; // addConnectUser(String, Object, Object?, Function)plaidClient;// stepConnectUser(String, String, Object?, Function)plaidClient;// getConnectUser(String, Object?, Function)plaidClient;// patchConnectUser(String, Object, Object?, Function)plaidClient;// deleteConnectUser(String, Object?, Function)plaidClient; // addIncomeUser(String, Object, Object?, Function)plaidClient;// stepIncomeUser(String, String, Object, Function)plaidClient;// getIncomeUser(String, Object?, Function)plaidClient;// patchIncomeUser(String, Object, Object?, Function)plaidClient;// deleteIncomeUser(String, Object?, Function)plaidClient; // addInfoUser(String, Object, Object?, Function)plaidClient;// stepInfoUser(String, String, Object, Function)plaidClient;// getInfoUser(String, Object?, Function)plaidClient;// patchInfoUser(String, Object, Object?, Function)plaidClient;// deleteInfoUser(String, Object?, Function)plaidClient; // addRiskUser(String, Object, Object?, Function)plaidClient;// stepRiskUser(String, String, Object, Function)plaidClient;// getRiskUser(String, Object?, Function)plaidClient;// patchRiskUser(String, Object, Object?, Function)plaidClient;// deleteRiskUser(String, Object?, Function)plaidClient; // getBalance(String, Function)plaidClient; // upgradeUser(String, String, Object?, Function)plaidClient; // exchangeToken(String, Function)plaidClient; // getLongtailInstitutions(Object, Function)plaidClient; // getAllInstitutions(Object, Function)plaidClient;
All parameters except options
are required. If the options parameter is omitted, the last argument to the function
will be interpreted as the callback.
Callbacks
For a request that could potentially return a MFA response, callbacks are in the form:
{ // err can be a network error or a Plaid API error (i.e. invalid credentials) // mfaResponse can be any type of Plaid MFA flow}
All add
, step
, and patch
related requests can return a MFA response. upgradeUser
can also return MFA responses.
For delete
, get
, getBalance
, and exchangeToken
requests, callbacks are in the form:
{ // err can be a network error or a Plaid API error (i.e. invalid credentials)}
Error Handling
The err
argument passed to either callback style can either be an instance of Error
or a Plaid API error object. An Error
object
is only passed back in the case of a HTTP connection error. The following code distinguishes
between a Plaid error and a standard Error instance:
{ if err != null if errcode != null // This is a Plaid error console; else // This is a connection error, an Error object console; }
Examples
Bank of America question-based MFA flow:
var plaid = ; // Initialize a clientvar plaidClient = 'test_id' 'test_secret' plaidenvironmentstartan; // Add a BofA auth user going through question-based MFAplaidClient;
Chase device-based MFA flow, including using the list:true
option to allow the user select
the device to send their security code to:
// Add a Chase user using the list:true optionplaidClient;
Retrieve transactions for a connect user for the last thirty days:
plaidClient;
Associate a new webhook with a connect user (webhook PATCH):
// Credentials are not required in this caseplaidClient;
Exchange a public_token
from Plaid Link for a Plaid access token and then
retrieve account data:
plaidClient;
Exchange a public_token
and account_id
from the Plaid + Stripe ACH
integration for a Plaid access token and a Stripe bank account token:
plaidClient;
Promise Support
You can "promisify" this library using a third-party Promise utility library such as Bluebird.
For example, using Bluebird's promisifyAll
functionality, we can do:
var bluebird = ;var plaid = ; // Promisify the plaid modulebluebird; var client = 'test_id' 'test_secret' plaidenvironmentstartan; // bluebird.promisifyAll(plaid) creates a promsified version of each method// in the client library suffixed with "Async"// i.e. getAuthUser's promsified counterpart is getAuthUserAsyncclient;
Callbacks that expect more than one argument pose a challenge for Bluebird. For Plaid API functions that may
return an mfa response, use the bluebird multiarg
option to get an array.
var bluebird = ;var plaid = ; var client = 'test_id' 'test_secret' plaidenvironmentstartan;var addAuthUserAsync = bluebird; ;
Support
Open an issue!
Tests
$ make test
Code coverage information is written to /coverage
.