Try Monique.io for free and save 93% of the time needed to set up dashboards and alerts.
The API gives you possibility to perform calculations based on input data encoded as JSON. The API can be conveniently used from a programming language supporting sending HTTP requests, or directly from a command-line interface using curl or similar tools.

API specification

The format of an API URL is:

http://calculator.vhex.net/c/<name>

where <name> is a name of a calculator. Full URLs with <name> filled are displayed at the bottom of a calculator page, which you can access from the main page.

Calculator's arguments must be encoded as a JSON array. Each type of arguments must be encoded as follows:

  • a single number - as a single number
  • a sequence/vector - as an array
  • a matrix - as an array of arrays (rows)

A JSON-encoded array with arguments must be passed directly as either GET or POST data. The preferred method is to use POST and set Content-Type HTTP header to application/json.

Returned data will be encoded as JSON. In case of an error, a response will have HTTP status code 400 (Bad Request) and will consist of a single string describing the error.

Examples

Variance of a sequence - command line usage
$ curl calculator.vhex.net/c/variance -d '[[1, 1.2, 0.8, 1.3]]'
0.036875
Passing a matrix - solving linear equations
$ curl calculator.vhex.net/c/linear-equations-solution -d '[ [[1, 2], [3, 4]], [1, 2] ]'
[
  0.0, 
  0.5
]
Generating random samples from the Gaussian distribution
$ curl calculator.vhex.net/c/gaussian -d '[5, 0, 1]' 
[
  1.3923079173126578, 
  0.21834478521029518, 
  0.07133951995455008, 
  -0.7950895862265774, 
  0.29889855429600454
]
Python example using requests library
import requests, json

args = [1,2,3,4,5]
r = requests.post('http://calculator.vhex.net/c/median',
    data=json.dumps([args]),
    headers={'content-type': 'application/json'})
result = r.json()

Using API from Google Apps Script
First we define a generic function for calling any API method:
function callCfx(url, argsArray) {
  var payload = JSON.stringify(argsArray);
  var options = {
     "method" : "post",
     "payload" : payload,
     "contentType": "application/json"
  };
  var result = UrlFetchApp.fetch(url, options);
  return JSON.parse(result.getContentText());
}
Now we can use it by passing API URL as the first argument and arguments as the second:
var res = callCfx('http://calculator.vhex.net/c/hamming-distance', [[1,2,3], [1,4,8]]);

Javascript example using jQuery
(due to restrictions on AJAX cross-domain calls this will not work when embedded in a web page)
$.ajax({
    url: 'http://calculator.vhex.net/c/k-means-clustering',
    data: JSON.stringify([ [[0,1,1], [0,1,2], [0,1,3]], 2 ]),
    success: function(data) {
        // data is a Javascript object - a number or an array
        alert(data);
    }
});

Usage limits

The API is free to use. It accepts input data sizes up to a few megabytes (which equals to hundreds of thousands of numbers). The access can be however throttled or a HTTP response 502 can be returned in case of high system load. Additionally time used by a single API call is limited to a few seconds.