Query
Simply build a JSON object with the same keys as in the parameters table above and execute the query method. Unlike Python, the query method in NodeJS returns a promise so be sure to catch it.
const liberator = require('liberator_module').liberator; //import liberator package in the liberator_module directory
//Add user/token credentials to this data object. You get these from CloudQuant
// Either create your own json file or simply replace the below json fields with strings
let credentials = {
user: JSON.parse(fs.readFileSync('liberator.json')).user,
token: JSON.parse(fs.readFileSync('liberator.json')).token,
}
//append credentials to query default so you dont hae to send them every time
liberator.set_default("query", credentials);
let params = {
as_of: “2021-01-12 23:59:59”
back_to: “2021-01-12 00:00:00”
symbols: "AAPL", //ticker symbol
name: "daily_bars", // Dataset name
};
//Example on how to query any dataset
liberator.query(params).then(function(results) {
… your code
});
Datasets
The datasets method returns a promise with a JSON Object of all the available datasets. Be sure to replace the dataset name in these examples with one for which you have been permissioned.
let dataset_params = {
schema: false,
details: true
};
//Example on how to query human readable data on all available datasets
liberator.datasets(dataset_params).then(function(results) {
… Your Code
})