# aw-client

> An ActivityWatch client library for JavaScript/NodeJS

Latest version **0.4.1** (published 2025-03-11) · MPL-2.0 license · 0 weekly downloads

## Install

```sh
npm install aw-client
pnpm add aw-client
yarn add aw-client
bun add aw-client
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 0.4.1 |
| Published | 2025-03-11 |
| First published | 2018-07-19 |
| Weekly downloads | 0 |
| License | MPL-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 52 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 40 |
| Author | Johan Bjäreholt |
| Maintainers | erb, johan-bjareholt |

## Links

- npm: https://www.npmjs.com/package/aw-client
- Repository: https://github.com/ActivityWatch/aw-client-js
- Issues: https://github.com/ActivityWatch/aw-client-js/issues
- npm.io page: https://npm.io/package/aw-client

## Recent versions

- 0.4.1 (latest) — 2025-03-11
- 0.4.0 — 2024-01-31
- 0.3.7 — 2023-11-15
- 0.3.6 — 2023-11-15
- 0.3.5 — 2023-10-19
- 0.3.4 — 2023-05-11
- 0.3.3 — 2022-04-26
- 0.3.2 — 2022-03-04
- 0.3.1 — 2022-03-03
- 0.3.0 — 2021-09-16
- 0.2.0 — 2020-07-16
- 0.1.0 — 2018-07-19

## README

# aw-client-js

Client library for [ActivityWatch](http://activitywatch.net) in TypeScript/JavaScript.

[![Build Status](https://github.com/ActivityWatch/aw-client-js/workflows/Build/badge.svg)](https://github.com/ActivityWatch/aw-client-js/actions)
[![npm](https://img.shields.io/npm/v/aw-client)](https://www.npmjs.com/package/aw-client)
[![Known Vulnerabilities](https://snyk.io/test/github/ActivityWatch/aw-client-js/badge.svg)](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
```

---
_Source: https://npm.io/package/aw-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
