Run a calculation in your browser!

In this post, we’re going to walk through how to run a calculation right from your browser.  It’s easy, kind of fun and very powerful!


To run a calculation from your browser, you need to use the Storage APIs and create an account.  This will allow you to persist usage data and other properties.  If you have not created an account yet, you can create one via the Genability APIs or via Genability Explorer and then be sure to load a profile to it, or manually enter some usage data.  To break this out into steps:


  • create the account (via APIs or Explorer)
  • upload a profile (via APIs or Explorer)
  • manually enter in usage data (via Explorer)
If you’re new to the Genability APIs, it may be quicker to use Explorer.  Your Storage data is available to you in both places.


Now that we have an account, let’s move on to the good stuff.
  • First, the calculation results are returned as JSON and if you’re using Chrome, we recommend downloading a JSON formatter plugin.  This indents and formats the json response directly in the browser window.  If you don’t use Chrome, there are several JSON formatting services.  Here is one we like.
  • Second, if you have an account, keep the account ID handy as we’ll be using it soon.  If you use Genability Explorer, you can find the account ID in the url.  If you use the APIs, this is the accountId of the object.  Example account id:
  • Third, paste the following url into your browser, swapping out your own accountId, appId and appKey.  This will run a calculation using the data stored in the account.
  • By default, it will use whatever properties are set at the account level and the calculation will be for the current month.  However, you can override any account property, change the date range, and set request parameters by appending query string parameters like so.  All query string parameters override the value of that property if it exists in the Account.
  • The above url runs a calculation that groups the results by Month and ChargeType for the masterTariffId=512.


If you do not have all the properties populated in the Account, we will make assumptions and return the assumptions we made as part of the calculation result.  You can review any assumptions used by examining the assumptions JSON object in the returned response.  In this example, the earliest data we have for this tariff begins 2011-03-01, but the request range is for the full year 2011, so we assume the same rates for the time frame for which we do not have coverage.

  • assumptions: [ 

      • keyName: “tariffId”,
      • dataType: “INTEGER”,
      • fromDateTime: “2010-12-31T19:00:00.000-05:00”,
      • toDateTime: “2011-03-01T00:00:00.000-05:00”,
      • dataValue: “512”,
      • accuracy: 0.5


      • keyName: “tariffId”,
      • dataType: “INTEGER”,
      • fromDateTime: “2011-03-01T00:00:00.000-05:00”,
      • toDateTime: “2011-12-31T19:00:00.000-05:00”,
      • dataValue: “512”,
      • accuracy: 1


      • keyName: “cityLimits”, <= Defaulted tariff property value
      • dataType: “STRING”,
      • fromDateTime: “2010-12-31T19:00:00.000-05:00”,
      • toDateTime: “2011-12-31T19:00:00.000-05:00”,
      • dataValue: “test2″,
      • accuracy: 0.8 <= arbitrary accuracy value



And that’s it.  Accounts are designed to make your life much easier when working with Genability services, whether via the APIs or Genability Explorer.  For more information about accounts, please refer to the developer documentation.

This entry was posted in API, Developers, Explorer and tagged , , . Bookmark the permalink. Both comments and trackbacks are currently closed.
  • Categories

  • Archives