REST API for LiveCompare External Data Sources

One of the things we’re looking at for LiveCompare 3.7 is the addition of a read-only REST API for external data sources (XDS). For several releases we’ve support a web services API that enables third-party software to integrate with LiveCompare workflows. The web services API lets application developers run LiveCompare workflows, including setting input parameters and access results. The programming model can be challenging because it is asynchronous. That and the fact that recently a class of applications that want to surface LiveCompare-computed data has made me think about supporting a simpler API.

Imagine you want to build an app that draws data from several applications, including LiveCompare, and presents the results in a dashboard. The dashboard reflects the current state of the data. A convenient way to configure LiveCompare would be to schedule a workflow to run periodically which stores its results in an XDS.

Now all we need is a way to get at the data from our dashboard app.

Enter the REST API for LiveCompare XDS.

Here’s my super-simple example dashboard:

Here’s the page source:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Default Chart</title>
    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
</head>
<body>
<div id="chart_div"></div>

<script type="text/javascript">
    google.charts.load('current', {'packages': ['corechart']});
google.charts.setOnLoadCallback(drawChart);

function drawChart() {
    $.getJSON("http://localhost/whitney/xds/ages.xdsx", function (data) {
   var data_table;
   var options;
   var chart;

   data_table = new google.visualization.DataTable(data);

   options = {
            'title': 'Ages',
            'width': 800,
            'height': 600
   };

   chart = new google.visualization.ColumnChart(
       document.getElementById("chart_div"));

   chart.draw(data_table, options);
    });
}
</script>
</body>
</html>

I’m using the Google Chart library. The data is retrieved by issuing an HTTP GET request to:

http://localhost/whitney/xds/ages.xdsx

which is an endpoint supported by LiveCompare 3.7.

I can test this from the command line using curl:

The response is JSON formatted and follows the Google DataTable schema. To make the response clearer I’ve reformatted it:L

{
  "cols": [
    {
      "id": "NAME",
      "label": "NAME",
      "type": "string"
   
},
    {
      "id": "AGE",
      "label": "AGE",
      "type": "number"
   
}
  ],
  "rows": [
    {
      "c": [
        {
          "v": "Bob"
       
},
        {
          "v": 45
        }
      ]
    },
    {
      "c": [
        {
          "v": "Alice"
       
},
        {
          "v": 46
        }
      ]
    },
    {
      "c": [
        {
          "v": "Susan"
       
},
        {
          "v": 23
        }
      ]
    },
    {
      "c": [
        {
          "v": "Mike"
       
},
        {
          "v": 19
        }
      ]
    }
  ]
}

I can also get just the schema of the table by appending ?schema to the URL:

To make the result clearer I’ve reformatted it:

{
  "fields": [
    {
      "name": "NAME",
      "type": "string"
   
},
    {
      "name": "AGE",
      "type": "number"
   
}
  ],
  "primaryKey": [
    "NAME"
 
]
}

 

Conclusion

We’re still working through some of the details but this post should give you an idea of the new XDS RESTful API we have planned for LiveCompare 3.7. Comments welcomed.