https://github.com/ActivityWatch/aw-client-js
Client library for ActivityWatch in JavaScript
https://github.com/ActivityWatch/aw-client-js
activitywatch javascript nodejs typescript
Last synced: 18 days ago
JSON representation
Client library for ActivityWatch in JavaScript
- Host: GitHub
- URL: https://github.com/ActivityWatch/aw-client-js
- Owner: ActivityWatch
- License: mit
- Created: 2016-04-28T06:33:51.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2025-03-11T12:04:03.000Z (about 1 month ago)
- Last Synced: 2025-03-16T16:28:34.896Z (about 1 month ago)
- Topics: activitywatch, javascript, nodejs, typescript
- Language: TypeScript
- Size: 274 KB
- Stars: 35
- Watchers: 4
- Forks: 17
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-activitywatch - aw-client-js
README
# aw-client-js
Client library for [ActivityWatch](http://activitywatch.net) in TypeScript/JavaScript.
[](https://github.com/ActivityWatch/aw-client-js/actions)
[](https://www.npmjs.com/package/aw-client)
[](https://snyk.io/test/github/ActivityWatch/aw-client-js)## Install
```sh
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.
```javascript
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
```sh
npm install
```### Build the library
```sh
npm run compile
```### Run the tests
```sh
npm test
```