@chirag127/wakatime
v1.0.0
Published
WakaTime v1 API client — coding stats, projects, languages
Downloads
65
Readme
@chirag127/wakatime
Zero-dependency WakaTime v1 API client. Node.js 18+.
Install
npm i @chirag127/wakatimeUsage
import { getStats, getAllTimeStats, getProjects, getUser } from '@chirag127/wakatime';
const KEY = process.env.WAKATIME_API_KEY;
// Coding stats for a range
const stats = await getStats(KEY, 'last_7_days');
// stats.total_seconds, stats.human_readable_total, stats.languages[], stats.projects[], stats.editors[]
// All-time stats
const allTime = await getAllTimeStats(KEY);
// allTime.total_seconds, allTime.text
// Projects list
const projects = await getProjects(KEY);
// projects[] — sorted by total_seconds desc
// Current user
const user = await getUser(KEY);
// user.username, user.email, ...API
All functions accept an API key and return the data field from the WakaTime response. Auth is Basic base64(apiKey).
| Function | Endpoint | Returns |
|---|---|---|
| getStats(apiKey, range?) | /api/v1/users/current/stats/{range} | stats object |
| getAllTimeStats(apiKey) | /api/v1/users/current/all_time_since_today | {total_seconds, text} |
| getProjects(apiKey) | /api/v1/users/current/projects | projects array |
| getUser(apiKey) | /api/v1/users/current | user object |
Default range: last_7_days. Other valid ranges: last_30_days, last_6_months, last_year, all_time.
License
MIT
