Code Monkey home page Code Monkey logo

wakatimejs's Introduction

wakatimejs

JavaScript client for consuming the WakaTime API.

Install

npm install wakatime

Usage

var WakaInstance = require('wakatime');

Set API Key

var wi = new WakaInstance('API_KEY');

or

var wi = new WakaInstance();
wi.setAPIKey('API_KEY');

Get API Key

var apiKey = wi.getAPIKey();
console.log(apiKey); // API_KEY

Get current user

wi.currentUser(function (error, response, user) {
    if (!error && response.statusCode == 200) {
        // the third parameter holds the user object
    }
});

Get stats

A user's logged time for the given time range. Range can be one of:

  • last_7_days
  • last_30_days
  • last_6_months
  • last_year
  • all_time
wi.stats('last_7_days', function (error, response, stats) {
    
});

Get summaries

A user's logged time for the given time range as an array of summaries segmented by day.

There are four ways to get your Waka summaries.

  1. By defining start and end date in YYYY-MM-DD format.

    wi.summaries({
        start: '2015-10-07',
        end: '2015-10-13'
    }, function (error, response, summary) {
        
    });
  2. By defining start and end date in a Date instance.

    wi.summaries({
        start: new Date(),
        end: new Date()
    }, function (error, response, summary) {
    
    });
  3. For single date summary, define the date in YYYY-MM-DD format.

    wi.summaries('2015-10-13', FUNCTION (error, response, summary) {
        
    });
  4. For single date summary, define the date in a Date instance.

    wi.summaries(new Date(), function (error, response, summary) {
        
    });

Get durations

A user's logged time for the given day as an array of duration blocks. There are two days to get durations.

  1. By defining the target date in YYYY-MM-DD format.

    wi.durations('2015-10-13', function (error, response, body) {
        
    });
  2. By defining the target date in a Date instance.

    wi.durations(new Date(), function (error, response, body) {
        
    });

License

MIT © Jillberth Estillore

wakatimejs's People

Contributors

jestillore avatar alanhamlett avatar

Watchers

 avatar  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.