nqm-api-tdx-stats
nquiringminds statistics API interface for nodejs clients (requires mongoDB >= 3.2)
Install
npm install nqm-api-tdx-stats
Test
npm test
Include
nodejs
const TDXApiStats = require("nqm-api-tdx-stats");
meteor
import TDXApiStats from "nqm-api-tdx-stats/client-api"
web page
Copy client-api.js (generated when you npm install) to your js directory then:
<script src="/path/to/client-api.js"></script>
Usage
Include in the appropriate manner as shown above
Passing a shared key:
const config = {
"commandHost": "https://cmd.nq-m.com",
"queryHost": "https://q.nq-m.com",
};
const tokenID = "token_id";
const tokenPass = "token_password";
const datasetID = "datasetID";
const api = new TDXApiStats(config);
api.setShareKey(tokenID, tokenPass);
api.getStdSample(datasetID, [], ["field"], 0)
.then((result) => {
// result = the result of the computation
});
Passing an existing token:
const config = {
"commandHost": "https://cmd.nq-m.com",
"queryHost": "https://q.nq-m.com",
"accessToken": "access_token",
};
const datasetID = "datasetID";
const api = new TDXApiStats(config);
api.getStdSample(datasetID, [], ["field"], 0)
.then((result) => {
// result = the result of the computation
});
Properties and Methods
Properties | Description |
---|
tdxApi | The nqm-tdx-api object |
Methods (authentication) | Description |
---|
setToken | Sets the token for the tdxApi object |
setShareKey | Sets the shared key for the tdxApi object |
Methods (first-order) | Description |
---|
getFirstOrder | Returns the first order statistic |
getMin | Returns the minimum for a set of fields |
getMax | Returns the maximum for a set of fields |
getSum | Returns the sum for a set of fields |
getAvg | Returns the average for a set of fields |
getStdPopulation | Returns the standard deviation (population) for a set of fields |
getStdSample | Returns the standard deviation (sample) for a set of fields |
getMed | Returns the median for a set of fields |
Methods (first-order chunking) | Description |
---|
getFirstOrderIterator | Returns an iterator object |
getFirstOrderChunk | Returns the first order statistic using the chunking method |
getMinChunk | Returns the minimum for a set of fields using the chunking method |
getMaxChunk | Returns the maximum for a set of fields using the chunking method |
getSumChunk | Returns the sum for a set of fields using the chunking method |
getAvgChunk | Returns the average for a set of fields using the chunking method |
getStdChunk | Returns the standard deviation for a set of fields using the chunking method |
Methods (second-order) | Description |
---|
getHistogram | Returns the histogram for a field |
Methods (second-order chunking) | Description |
---|
getHistogramChunk | Returns the histogram for a field using the chunking method |
Methods (first-order indexed) | Description |
---|
getMinIndexed | Returns the minimum for an indexed field |
getMaxIndexed | Returns the maximum for an indexed field |
Methods (second-order indexed) | Description |
---|
getHistogramIndexed | Returns the histogram for an indexed field |