BkperApp GSTests status

BkperApp is a Google Apps Script library for Bkper.

With BkperApp you can create many solutions on G Suite, such as the Sheets and Forms Add-ons, simple automations or advanced solutions with Google Apps Script API, and you can manage your scripts in the Dashboard.

It works the same way your favorite Google Apps Script library works, like CalendarApp, DocumentApp, SpreadsheetApp etc, and it is safely authorized using OAuth2 protocol:

BkperApp overview


To authorize the library, you just need to run the OAuth2 flow only once per account. This can be easily done when you install any Add-ons, or by clicking and running this authorization script


This library is already published as an Apps Script, making it easy to include in your project. To add it to your script, do the following in the Apps Script code editor:

  1. Click on the menu item "Resources > Libraries..."
  2. In the "Find a Library" text box, enter the project key "My8jgp9C1MEeWVxuYNppyFgoOxUd2qb-3" and click the "Select" button.
  3. Choose a version in the dropdown box (usually best to pick the latest version).
  4. Click the "Save" button.

Record Transactions

To record your first Transaction, after authorizing and setup, copy and paste the function bellow:

function recordATransaction() {

  var book = BkperApp.openById("agtzfmJrcGVyLWhyZHIOCxIGTGVkZ2VyGNKJAgw");

  book.record("#gas 63.23");


Exchange the parameter of the function openById for the id of the Book you want to record the Transaction. This is the same parameter found on the URL accessed on bkper.com:


Now run the recordATransaction function and see the record appearing on the bkper screen:


You can also record transactions in batch by passing an Array of strings as the record method parameter:

function batchRecordTransactions() {

  var book = BkperApp.openById("agtzfmJrcGVyLWhyZHIOCxIGTGVkZ2VyGNKJAgw");

  var transactions = new Array();

  transactions.push("#breakfast 15.40");
  transactions.push("#lunch 27.45");
  transactions.push("#dinner 35.86");



The above code will send all records in a bulk. Very useful for importing large amount of data without the risk of reaching script limits.

Query Transactions

Each book is a large database and every interaction is done in terms of queries. Everytime you "select" an Account by clicking on left menu at bkper.com, you are actually filtering transactions by that Account.

Every query is shown in the search box on top of the page:


When you search transactions, the search method returns an TransactionIterator to let you handle potentially large datasets:

function queryTransactions() {

  var book = BkperApp.openById("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgKCtg6MLDA");

  //Search returns an interator to deal with potencial large datasets
  var transactionIterator = book.search("acc:'Bank' after:01/04/2014");

  while (transactionIterator.hasNext()) {
    var transaction = transactionIterator.next();


Run the queryTransactions function, exchanging your bookId, with the same query, check the log output and you will see the same descriptions:

Search log

List Accounts Balances

You can access all Account objects, and query its balances, in a way similar to the left sidebar:

function listAccountBalances() {
  //Open the book
  var book = BkperApp.openById("agtzfmJrcGVyLWhyZHIOCxIGTGVkZ2VyGNKJAgw");

  var accounts = book.getAccounts();
  for (var i=0; i < accounts.length; i++) {
    var account = accounts[i];
    if (account.isPermanent() && account.isActive()) {
      Logger.log(account.getName() + ": " + account.getBalance());

Query Balances over time

it is very easy to query balances of Accounts and #hashtags over time, getting period and cumulative balances. Balance queries are used in bkper.com to generate chart reports:

Balance Queries

You can easily run balance queries on your script, by calling the function getBalanceReport, like the example bellow:

Deploy as web app to get the generated Charts
function doGet() {

  //Open the book
  var book = BkperApp.openById("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgKCtg6MLDA");

  //Query for balances
  var report = book.getBalanceReport("= group:'Expenses' group:'Incomes' after:01/2014 before:02/2014");

  //Create data table builder
  var dataTableBuilder = report.createDataTable().setBalanceType(BkperApp.BalanceType.TOTAL);

  //Create chart
  var chartsDataTable = dataTableBuilder.buildChartDataTable();
  var pieChart = Charts.newPieChart().setDataTable(chartsDataTable).build();
  var tableChart = Charts.newTableChart().setDataTable(chartsDataTable).build();

  //Add to UI
  var ui = UiApp.createApplication();

  return ui;


Exchange the book id and the query, deploy and run the script as a web app, and you will get a report like this live example.