Discretionary funds less credit card spending via Plaid API + Firebase Functions
Endpoint to provide your current "real" balance using the Plaid API. The function totals up your depository (checking) accounts as well as credit accounts and returns the difference.
Further reading:
See file functions/index.js for the code.
The dependencies are listed in functions/package.json.
- Clone or download this repo and open the
real-balance
directory.
- Create a Firebase Project using the Firebase Developer Console
- Enable billing on your project by switching to the Blaze or Flame plan. See pricing for more details. This is required to allow requests to non-Google services within the Function.
- Install Firebase CLI Tools if you have not already, and log in with
firebase login
. - Configure this sample to use your project using
firebase use --add
and select your project.
- Install dependencies locally by running:
cd functions; npm i; cd -
- Add your Plaid API credentials and basic auth password to the Firebase config:
firebase functions:config:set \ plaid.clientid=<YOUR PLAID CLIENT ID> \ plaid.secret=<YOUR PLAID SECRET> \ user.password=<YOUR BASIC AUTH PASSWORD>
- You will also need to add an array of Plaid
access_token
's for each Plaid Item you would like included in your "real" balance. You may also (optionally) add an array of specific accounts to be used with eachaccess_token
, otherwise all accounts will included.firebase functions:config:set \ plaid.items.0.token=<FIRST PLAID ACCESS TOKEN> \ plaid.items.1.token=<ANOTHER PLAID ACCESS TOKEN> \ plaid.items.1.account_ids.0=<A SPECIFIC ACCOUNT ID> \ plaid.items.1.account_ids.1=<ANOTHER SPECIFIC ACCOUNT ID>
- Deploy your function using
firebase deploy --only functions
- After deploying the function you can use the your basic auth credentials to access the endpoint at:
https://us-central1-<project-id>.cloudfunctions.net/balance