I would like to write a Google Apps Script that can pull transaction data from my bank and add it to a google spreadsheet. I thought Plaid might be a good option, but I am unable to figure out how I would use the Plaid API within google apps script. Plaid supports Node.js while Google Apps Script uses a JavaScript cloud scripting language.
Google Apps Script does allow you to use external APIs but I believe Plaid makes you add a bank through Link.
Does anyone have any idea of a better way to do this?
Thanks!
I would like to write a Google Apps Script that can pull transaction data from my bank and add it to a google spreadsheet. I thought Plaid might be a good option, but I am unable to figure out how I would use the Plaid API within google apps script. Plaid supports Node.js while Google Apps Script uses a JavaScript cloud scripting language.
Google Apps Script does allow you to use external APIs but I believe Plaid makes you add a bank through Link.
Does anyone have any idea of a better way to do this?
Thanks!
Share Improve this question asked Apr 17, 2018 at 0:22 Emma F.Emma F. 832 silver badges5 bronze badges 1- Looks like they require a client library, and don't directly expose a REST API. Unless you can get a viable Javascript client library that can run in JS 1.6, without persistent state (every isolated call to Apps Script is a new instance), you'll need a different medium. – tehhowch Commented Apr 17, 2018 at 0:27
3 Answers
Reset to default 13founder of Plaid here. I've actually done this for some of my personal projects! What I did was to use one of the quickstart apps to generate an access_token
(doc) then just send a request to /transactions/get
(doc) in the google script. So pretty much the entire script would just be sending one HTTP request then parsing the data and formatting into the google sheets as you see fit.
One gotcha I ran up against is Google sheets actually proxies your requests through their system and heavily caches and rate limits those requests. I think this was in response to the old days where you could practically build a bot net and DOS a site using Google's infra via Sheets.
Hope that helps!
co-founder of bkper. here.
We use Plaid to offer direct bank connections to users, offering a Google Apps Script library to easily allow access to data, under a secure OAuth2 layer.
You can use it to access your data without the need to worry about implement Link connections and tokens management :-)
Former Plaid employee here. Here's an example of getting balance for the first account for an item. Retrieves every 12 hours in this example, but that logic can be removed.
function getBalance() {
var cache = CacheService.getScriptCache();
var lastUpdated = cache.get('lastUpdated');
// update every 12 hours
if (lastUpdated == null || Date.now() - Date.parse(lastUpdated) > 1000 * 60 * 60 * 12) {
var payload = {
"client_id": "your_client_id",
"secret": "your_secret",
"access_token": "relevant_access_token",
"options": {
"account_ids": ["account_id1", "account_id2"]
}
};
var res = UrlFetchApp.fetch("https://production.plaid./accounts/balance/get", {'method': 'post', 'contentType': 'application/json', 'payload': JSON.stringify(payload)});
var obj = JSON.parse(res.getContentText());
var ret = obj.accounts[0].balances.available;
cache.put('lastBalance', String(ret));
cache.put('lastUpdated', new Date().toISOString());
return ret;
}
return Number(cache.get('lastBalance'));
}