Skip to content

ActivityWatch/aw-client-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

b2e02b3 · Mar 11, 2025
Mar 9, 2025
Mar 11, 2025
Jan 18, 2019
Apr 26, 2022
Jun 7, 2018
Apr 26, 2022
Jan 23, 2023
Apr 26, 2022
Jan 31, 2024
Mar 11, 2025
Mar 11, 2025
Nov 15, 2023
Jan 31, 2024

Repository files navigation

aw-client-js

Client library for ActivityWatch in TypeScript/JavaScript.

Build Status npm Known Vulnerabilities

Install

npm install aw-client

Usage

The 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');
const client = new AWClient('test-client')

// Get server info
client.getInfo().then(console.log);

// List buckets
client.getBuckets().then(console.log);

// Create bucket
const bucketId = "test";
client.createBucket(bucketId, "bucket-type", "your-hostname");

// Send a heartbeat
const nowStr = (new Date()).toISOString();
const heartbeat = {timestamp: nowStr, duration: 0, data: { label: "just testing!" }};
client.heartbeat(bucketId, 5, heartbeat);

Contribute

Setup your dev environment

npm install

Build the library

npm run compile

Run the tests

npm test