JavaScript client for consuming the WakaTime API.
npm install wakatime
var WakaInstance = require('wakatime');
var wi = new WakaInstance('API_KEY');
or
var wi = new WakaInstance();
wi.setAPIKey('API_KEY');
var apiKey = wi.getAPIKey();
console.log(apiKey); // API_KEY
wi.currentUser(function (error, response, user) {
if (!error && response.statusCode == 200) {
// the third parameter holds the user object
}
});
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) {
});
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.
-
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) { });
-
By defining start and end date in a
Date
instance.wi.summaries({ start: new Date(), end: new Date() }, function (error, response, summary) { });
-
For single date summary, define the date in
YYYY-MM-DD
format.wi.summaries('2015-10-13', FUNCTION (error, response, summary) { });
-
For single date summary, define the date in a
Date
instance.wi.summaries(new Date(), function (error, response, summary) { });
A user's logged time for the given day as an array of duration blocks. There are two days to get durations.
-
By defining the target date in
YYYY-MM-DD
format.wi.durations('2015-10-13', function (error, response, body) { });
-
By defining the target date in a
Date
instance.wi.durations(new Date(), function (error, response, body) { });
MIT © Jillberth Estillore