Wouldn’t it be cool to have your Bank balances in your spreadsheet automatically up to date? With open banking, this will become more and more common. This is how you get your balances from Up Bank.
Go to script editor to add a custom function.
Copy the following, and replace the contents of the script to:
function FetchAccounts(token, placeholder) {
const url = "api.up.com.au/api/v1/accounts"
const params = {
'headers': {
'authorization': 'Bearer ' + token,
}
}
const response = UrlFetchApp.fetch(url, params);
const data = JSON.parse(response.getContentText()).data
const result = data.map(function(obj){
return [obj.attributes.displayName, obj.attributes.balance.valueInBaseUnits]
})
return result;
}
Then save the project as any name you want. I called it UpBank.
Along the way it may prompt you to add some permissions. Simply authorise your script to be allowed to run on Google Sheets.
Then, back in Google Sheets, simply call the function
=FetchAccounts("up:yeah:xxxxx", 0)
- The first argument being your bearer token. You can follow Up’s guide to get access to your token.
2. The second argument is a placeholder. Most users don’t have to worry about it, just set it to 0.
- This can be used to automatically fetch your account balances if you have another script incrementing this value. A use case is to automatically record your balance over time.
You’ll now have your account balances in Google Sheets 🎉