Giter VIP home page Giter VIP logo

databox-js's Introduction

databox-js

Build Status npm version

Installation

npm install databox

Usage

var Databox = require('databox');

var client = new Databox({
    push_token: '<my token>'
});

// Push one KPI
client.push({
    key: 'js.prices.gas',
    value: 322,
    date: '2018-02-23 09:00:00'
}, function(result){
    console.log(result);
});

// Push multiple KPIs
client.insertAll([
    {
        key: 'js.prices.gas',
        value: 322
    },
    {
        key: 'js.prices.gas',
        value: 100,

        // With date
        date: '2018-02-23 09:00:00'
    },
    {
        key: 'js.prices.gas',
        value: 200,

        // With additional attributes
        attributes: {
            'station': 'ny-main'
        }
    },
    {
        key: 'js.prices.gas',
        value: 200,

        // With additional currency unit
        unit: 'USD'
    }
], function(result){
    console.log(result);
});

// Callback is optional
client.insertAll([
    {
        key: 'js.prices.gas',
        value: 322
    },
    {
        key: 'js.prices.gas',
        value: 100,
        date: '2018-02-23 09:00:00'
    }
]);

// Get last push
client.lastPush(function (pushes) {
    console.log(pushes);
});

// Retrieve several pushes
client.lastPushes(10, function (pushes) {
    console.log(pushes);
});

// Retrieve specific push
var id = '14714784007cb9cd36cf46baefcd0a';
client.getPush(id, function (pushes) {
    console.log(pushes);
});

// Retrieve pushed metric keys
client.metrics(function (metrics) {
    console.log(metrics);
});

// Purge pushed data
client.purge(function (response) {
    console.log(response);
});

Development

git clone ...
npm test

Debugging

# Add "debugger" keyword anywhere and run
mocha debug test

Author & Licence

Comes with MIT.

databox-js's People

Contributors

otobrglez avatar vladapetrovic avatar colxi avatar thorro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.