Skip to content

jestillore/wakatimejs

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 

wakatimejs

JavaScript library for getting data of the WakaTime API. Currently, you can only retrieve data by using your WakaTime API Key

Install

npm install wakatime

or

yarn add wakatime

Usage

import {WakaTime} from "wakatime"

Set API Key

const wakaTimeInstance = new WakaTime('API_KEY')

or

const wakaTimeInstance = new WakaTime()
wakaTimeInstance.apiKey = 'API_KEY'

Get API Key

const apiKey = wakaTimeInstance.apiKey
console.log(apiKey) // API_KEY

Get current user

wakaTimeInstance.currentUser()
    .then((resp) => console.log(resp))
    .catch((err) => console.log(err))

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
wakaTimeInstance.stats('last_7_days').then().catch()

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 WakaTime summaries.

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

    wakaTimeInstance.summaries({
        start: '2015-10-07',
        end: '2015-10-13'
    }).then().catch()
  2. By defining start and end date in a Date instance.

    wakaTimeInstance.summaries({
        start: new Date(),
        end: new Date()
    }).then().catch()
  3. For single date summary, define the date in YYYY-MM-DD format or use a JS Date.

    wakaTimeInstance.summaries('2015-10-13').then().catch()
    wakaTimeInstance.summaries(new Date()).then().catch()

Get durations

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

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

    wakaTimeInstance.durations('2015-10-13').then().catch()
  2. By defining the target date in a Date instance.

    wakaTimeInstance.durations(new Date()).then().catch()

Authors

License

MIT

About

JavaScript client for consuming the WakaTime API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published