SmartOrg API

The SmartOrg API allows you to build modern Javascript applications on top of SmartOrg's portfolio evaluation technology.

What you need

  • API software
  • Access to our servers
    To receive our software and an account on our servers, please write to us about your interest.

View the API

Take a look at the API documentation which comes with code examples. This is targeted at developers, and relies on some foundational concepts around Portfolio Management.

Using the API

All usage begins with creating a SmartOrg object.

var endpoint = "https://localhost";
var path = "kirk";
var smartorg = new SmartOrg(endpoint, path);

The first step is to authenticate.

var username = ...; // get the username from somewhere
var password = ...; // get the password from somewhere
smartorg.authenticate({'username': username, 'password': password})
 .then(function (userInfo) {"user ID " + userInfo.uid + " logged in");
 .catch(function (err) {
     console.error("Error occurred "+err);

Once authentication is complete, you can use the API to use the SmartOrg platform.

Obtain a list of portfolios

You can fetch all the portfolios available to the user.

.then(function (portfolios) { (portfolio) {
.catch(function (err) {

Obtain tree for a portfolio

Each portfolio has a tree structure, which you can pull out.

.then(function (treeNodes) { (treeNode) {
.catch(function (err) {

The tree structure is returned as an array of nodes, and each node has an array of children node pointers. You can construct a tree in memory by putting each node into a hash, and recursing starting from the root node.
You can identify the root node in one of two ways:

  • treeID == name
  • parent array is null

One way of doing this could be:

rootNode = treeNodes.filter(
function(treeNode) {
    return treeNode.treeID ===;
    // You could also do:
    // return treeNode.parent === null;

The rootNode is like any other Node. You can construct your tree visualization by going through a
node's children. To do this, you would first want to construct a dict of all the nodes using treeNodes,
which you obtained earlier with a call to smartorg.treeFor:

var allNodes = {};
treeNodes.forEach(function(treeNode) { 
allNodes[treeNode._id] = treeNode;

Now that we have a dict built up, and we also have the rootNode, we can do a simple depth first tree traversal and print out the tree in the console, like so:

function traverse(node, level) {
    var tabs = "";
    for (i=0;i<level;i++) { tabs += "  ";}
    node.children.forEach(function(childNodeID) {
        traverse(allNodes[childNodeID], level+1);    
traverse(rootNode, 0);

Obtain a node

You can also pull a single node by its id, like so:

    then(function(node) {

If you have handled your objects efficiently and have the allNodes dict in your context, you may not need to pull in a node individually and can straightaway do a dict lookup.

Obtain action menu for node

The node object gives you structural information that lets you construct an action menu for that node. In order to obtain the action menu associated with any node, you can use actionMenuFor. This function returns a callback that provides a (menu object)[global.html#PromiseActionMenuCallbackSuccess]. Here is an example that prints out the menu action titles of a node in the console:

    .then(function(menu) {
        menu.menuItems.Actions.forEach(function(action) {
    .catch(function (err) {
        // handleError

You can look at the other attributes of a menu action.

Obtain results of running action

Once you have the action menu item, you can execute the command associated with it and fetch the results. To do this, you would need actionFor.

Here's an example:

 smartorg.actionFor(actionID, nodeID)
    .then(function(data) {

    .then(function(err) {
        // handleError