A NodeJS
client for the WakaTime
API.
npm install wakatime-client --save
- Create Instance Using API Key
getUser
getMe
getTeams
getMyTeams
getUserAgents
getMyUserAgents
getTeamMembers
getMyTeamMembers
getTeamMemberSummary
getMyTeamMemberSummary
getUserSummary
getMySummary
getUserStats
getMyStats
getProjects
getMyProjects
getLeaders
getHeartbeats
getMyHeartbeats
getGoals
getMyGoals
getDurations
getMyDurations
getCommits
getMyCommits
getMetadata
getOrganizations
getMyOrganizations
getOrganizationDashboards
getMyOrganizationDashboards
getOrganizationDashboardMembers
getMyOrganizationDashboardMembers
getOrganizationDashboardMemberSummaries
getMyOrganizationDashboardMemberSummaries
getOrganizationDashboardMemberDurations
getMyOrganizationDashboardMemberDurations
import { WakaTimeClient } from 'wakatime-client';
const client = new WakaTimeClient('some api key');
import { WakaTimeClient } from 'wakatime-client';
const client = new WakaTimeClient('some api key', 'https://wakapi.dev/api/v1');
Get details for user
const userDetails = await client.getUser('some user id');
Get details for user associated with API key
const myUserDetails = await client.getMe();
Get teams for user
const teams = await client.getTeams('some user id');
Get teams for user associated with API key
const myTeams = await client.getMyTeams();
Get User Agents
(or plugins) for user
const userAgents = await client.getUserAgents('some user id');
Get User Agents
(or plugins) for user associated with API key
const myUserAgents = await client.getMyUserAgents();
Get team members for specified user and team
const teamMembers = await client.getTeamMembers({ userId: 'some user id', teamId: 'some team id' });
Get team members for user associated with API key and specified team
const myTeamMembers = await client.getMyTeamMembers('some team id');
Get summary for team member
const teamMemberSummary = await client.getTeamMemberSummary({
userId: 'some user id',
teamId: 'some team id',
teamMemberId: 'some team member id',
dateRange: {
startDate: 'some start date',
endDate: 'some end date',
},
});
const teamMemberSummary = await client.getTeamMemberSummary({
userId: 'some user id',
teamId: 'some team id',
teamMemberId: 'some team member id',
dateRange: {
startDate: 'some start date',
endDate: 'some end date',
},
projectName: 'some project name',
branchNames: ['some branch', 'some other branch', 'some other other branch'],
});
Get summary for team member for user associated with API key
const myTeamMemberSummary = await client.getMyTeamMemberSummary({
teamId: 'some team id',
teamMemberId: 'some team member id',
dateRange: {
startDate: 'some start date',
endDate: 'some end date',
},
});
const myTeamMemberSummary = await client.getMyTeamMemberSummary({
teamId: 'some team id',
teamMemberId: 'some team member id',
dateRange: {
startDate: 'some start date',
endDate: 'some end date',
},
projectName: 'some project name',
branchNames: ['some branch', 'some other branch', 'some other other branch'],
});
Get summary for user
const summary = await client.getUserSummary({
userId: 'some user id',
dateRange: {
startDate: 'some start date',
endDate: 'some end date',
},
})
const summary = await client.getUserSummary({
userId: 'some user id',
dateRange: {
startDate: 'some start date',
endDate: 'some end date',
},
projectName: 'some project name',
branchNames: ['some branch', 'some other branch', 'some other other branch'],
})
Get summary for user associated with API key
const summary = await client.getMySummary({
dateRange: {
startDate: 'some start date',
endDate: 'some end date',
},
})
const summary = await client.getMySummary({
dateRange: {
startDate: 'some start date',
endDate: 'some end date',
},
projectName: 'some project name',
branchNames: ['some branch', 'some other branch', 'some other other branch'],
})
Get stats for user
import { RANGE } from 'wakatime-client';
// I assume you have instantiated the client
const stats = await client.getUserStats({
userId: 'some user id',
range: RANGE.PAST_7_DAYS,
});
import { RANGE } from 'wakatime-client';
// I assume you have instantiated the client
const stats = await client.getUserStats({
userId: 'some user id',
range: RANGE.PAST_7_DAYS,
timeout: 'some timeout',
useWritesOnly: true,
projectName: 'some project name',
});
Get stats for user associated with API key
import { RANGE } from 'wakatime-client';
// I assume you have instantiated the client
const myStats = await client.getMyStats({ range: RANGE.PAST_7_DAYS });
import { RANGE } from 'wakatime-client';
// I assume you have instantiated the client
const myStats = await client.getMyStats({
range: RANGE.PAST_7_DAYS,
timeout: 'some timeout',
useWritesOnly: true,
projectName: 'some project name',
});
Get projects for user
const projects = await client.getProjects('some user id');
Get projects for user associated with API key
const myProjects = await client.getMyProjects();
Get Leaders
const leaders = await client.getLeaders();
const leaders = await client.getLeaders({ language: 'JavaScript', pageNumber: 2 });
Get heartbeats for user on a specified date
const heartbeats = await client.getHeartbeats({ userId: 'some user id', date: 'some date' });
Get heartbeats for user associated with API key on a specified date
const myHeartbeats = await client.getMyHeartbeats('some date');
Get goals for user
const goals = await client.getGoals('some user id');
Get goals for user associated with API key
const myGoals = await client.getMyGoals();
Get durations for user
const durations = await client.getDurations({ userId: 'some user id', date: 'some date' });
const durations = await client.getDurations({
userId: 'some user id',
date: 'some date',
projectName: 'some project name',
branchNames: ['some branch', 'some other branch', 'some other other branch'],
});
Get durations for user associated with API key
const myDurations = await client.getMyDurations({ date: 'some date' });
const myDurations = await client.getMyDurations({
date: 'some date',
projectName: 'some project name',
branchNames: ['some branch', 'some other branch', 'some other other branch'],
});
Get commits for user
const commits = await client.getCommits({
userId: 'some user id',
projectName: 'some project name',
});
const commits = await client.getCommits({
userId: 'some user id',
projectName: 'some project name',
authorName: 'jaebaebae',
pageNumber: 2,
});
Get commits for user associated with API key
const myCommits = await client.getMyCommits({ projectName: 'some project name' });
const myCommits = await client.getMyCommits({
projectName: 'some project name',
authorName: 'jaebaebae',
pageNumber: 2,
});
Get metadata associated with WakaTime service (like IP addresses)
const metadata = await client.getMetadata();
Get list of organizations for the specified user
const organizations = await client.getOrganizations('some user id');
Get list of organizations for user associated with API key
const myOrganizations = await client.getMyOrganizations();
Get list of dashboards for the specified user and organization
const dashboards = await client.getOrganizationDashboards({
userId: 'some user id',
organizationId: 'some organization id',
});
Get list of dashboards for the current user and the specified organization
const dashboards = await client.getMyOrganizationDashboards('some organization id');
Get list of dashboard members for the specified user, organization, and dashboard
const members = await client.getOrganizationDashboardMembers({
userId: 'some user id',
organizationId: 'some organization id',
dashboardId: 'some dashboard id',
})
Get list of dashboard members for the current user and specified organization and dashboard
const members = await client.getMyOrganizationDashboardMembers({
organizationId: 'some organization id',
dashboardId: 'some dashboard id',
})
Get list of dashboard member summaries for the specified user, organization, dashboard, and member
const summaries = await client.getOrganizationDashboardMemberSummaries({
userId: 'some user id',
organizationId: 'some organization id',
dashboardId: 'some dashboard id',
memberId: 'some member id',
})
Get list of dashboard member summaries for the current user and specified organization, dashboard, and member
const summaries = await client.getMyOrganizationDashboardMemberSummaries({
organizationId: 'some organization id',
dashboardId: 'some dashboard id',
memberId: 'some member id',
})
Get list of dashboard member durations for the specified user, organization, dashboard, and member
const summaries = await client.getOrganizationDashboardMemberDurations({
userId: 'some user id',
organizationId: 'some organization id',
dashboardId: 'some dashboard id',
memberId: 'some member id',
})
Get list of dashboard member durations for the current user and specified organization, dashboard, and member
const summaries = await client.getMyOrganizationDashboardMemberDurations({
organizationId: 'some organization id',
dashboardId: 'some dashboard id',
memberId: 'some member id',
})
After cloning the repository, use nvm
/ npm
to install dependencies.
To run tests, execute npm run test
. This will run both unit and integration tests.
In order to execute local integration tests successfully, you'll need to specify the following environment variables in the .env
file as well as in the Secrets
section of your fork's Settings
page.
ACCESS_TOKEN
(A WakaTime Access Token)USER_ID
(A WakaTime User ID)ORGANIZATION_ID
( A WakaTime Organization ID)DASHBOARD_ID
(A WakaTime Dashboard ID)
To build the production bundle, execute npm run build
.
This project uses husky
to maintain git hooks.
pre-commit
- runeslint
commit-msg
- run commit message lintingpre-push
- run tests
This project uses semantic-release
and commitlint
(specifically the Angular commit convention) to automatically enforce semantic versioning.