Client library for ActivityWatch in TypeScript/JavaScript.
npm install aw-clientThe library uses Promises for almost everything, so either use .then() or async/await syntax.
The example below is written with .then() to make it easy to run in the node REPL.
const{ AWClient }=require('aw-client');constclient=newAWClient('test-client')// Get server infoclient.getInfo().then(console.log);// List bucketsclient.getBuckets().then(console.log);// Create bucketconstbucketId="test";client.createBucket(bucketId,"bucket-type","your-hostname");// Send a heartbeatconstnowStr=(newDate()).toISOString();constheartbeat={timestamp: nowStr,duration: 0,data: {label: "just testing!"}};client.heartbeat(bucketId,5,heartbeat);npm installnpm run compilenpm test