GithubHelp home page GithubHelp logo

metry-sdk-es6's Introduction

Unofficial ES6 SDK for metry.io API

This SDK is still in early development. It should definitely not be used for production code.

This is the only "documentation" there is:

import {MetrySDK, MetryPrivateTokenAuthTransform} from 'metry-sdk-es6';

const baseURL = 'https://app.metry.io/api/v2';
const apiToken = '<private token>';
const auth = new MetryPrivateTokenAuthTransform(apiToken);
const metry = new MetrySDK(baseURL, auth);

// Changes my account's name to Mr. Robot
(async function () {
    let me = (await metry.resource('accounts').get('me')).data;
    console.dir(await metry.resource('accounts').save({'_id': me._id, name: 'Mr. Robot'}));
})();

// Returns the list of active meters
(async function () {
    console.dir(await metry.resource('meters').query({box: 'active'}));
})();

// So does this...
(async function () {
    console.dir(await metry.query('meters', {box: 'active'}));
})();

// You can either create a resource, like meters:
let Meters = metry.resource('meters');

// and use it like:
Meters.query({param: 'value'})

// or directly use:
metry.query('meters', {param: 'value'})

// To get time series data, like consumptions:
(async function () {
    console.dir(await metry.getTimeSeries('consumptions', '<meter id>', '<month|day|hour>', '<range, see metry api docs>'));
})();

metry-sdk-es6's People

Contributors

toostn avatar

Stargazers

Tuğrul Can avatar

Watchers

 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.