-
Credentials are stored in
lib/credentials.json. This is checked into the repo, so USE A PRIVATE REPO. Do not use a public fork and accidentally push your tokens to it! I will not take responsibility for any potential leak of sensitive information. -
All this repo does is talking to Plaid/Google APIs and writing tokens to your local file system. If you don't feel safe entering real bank credentials, audit the code yourself to make sure.
-
You will first need to sign up for Plaid and apply for the development plan. You might need to wait for a day or two to get approved. It's free and limited to 100 items (i.e. banks), so it should be more than enough for your personal use.
-
Once approved, fill out
client_id,secretandpublic_keyinlib/credentials.jsonunderplaid. -
Now you need to connect to your financial institutions to generate access tokens.
Run
npm run token-plaid <account>whereaccountis an id for the bank you want to connect (it's for your personal reference, so you can name it anything). This will start a local server which you can visit in your browser and go through the authentication flow. Once you've linked the bank, its associated access token will be written tolib/credentials.jsonunderplaid.tokens.<account>.This process needs to be repeated for each bank you want to connect. Make sure to run each with a different
accountname. -
If you've done everything correctly, running
npm run test-plaidnow should log the recent transactions in your connected accounts.
I use a Google Sheet because it's convenient. If you want to build your own fancy interface, you can totally do that - but that's out of scope for this demo.
-
First, create a Google Sheets spreadsheet, and save its ID in
lib/credentials.jsonassheets.sheet_id. -
Then, go to Google Sheets API Quickstart, and click the "Enable the Google Sheets API" button. Follow instructions and download the JSON file. Copy the following fields into
lib/credentials.jsonundersheets:client_idclient_secretredirect_uris
-
Run
npm run token-sheets. This will prompt for auth and save the token inlib/credentials.jsonundersheets.token. -
Now run
npm run test-sheets. You should see your sheet's cell A1 with "It worked!".
-
With the APIs sorted out, now it's time to connect them. Open
lib/transform.js- this is where you can write your own logic to map incoming transactions to cell updates. How to structure the spreadsheet to use that data is up to you. -
By default, the transaction date range is from the beginning of last month to now. You can adjust this in
lib/fetch.js. -
Once you've setup your own transform logic, run
node index.js. If everything works, your spreadsheet should have been updated. -
This repo only handles transactions, but it should be pretty straightforward to add balances.
The repo contains a CircleCI config file which runs the update every day at 5AM UTC (midnight US Eastern time). All you need to do is setup your project on CircleCI and that's it (again, make sure to use a private repo). You can adjust the cron config to tweak the time/frequency of the updates.