Skip to content
v1
Docs

Node.js SDK

Node.js SDK

The Node.js SDK calls the WatchTower15 API, counts what your application does as custom metrics and ships its logs to log ingest, from one WatchTower15 client. It builds, retries and batches the calls for you, and turns every failure into a typed error. It has no runtime dependency, uses fetch, and ships ES modules, CommonJS and TypeScript declarations.

  • The REST API. Every /v1 operation is a method on a resource: wt15.servers.list(), wt15.incidents.acknowledge(uuid). See the REST API.
  • Custom metrics. Push points, or count in the request path with the aggregator and let a flush send them once a minute. See custom metrics.
  • Logs. A logger, a pino transport and a winston transport that send lines to log ingest. See logs.
You use Install Page
Anything npm install @watchtower15/sdk this page
pino npm install @watchtower15/pino Logs
winston npm install @watchtower15/winston Logs
NestJS 11 or 12 npm install @watchtower15/nestjs NestJS

The integrations require the core, @watchtower15/sdk, as a peer, so install both. All four packages are released together, at one version. For Express, Fastify, Hono and Next.js there is no package, only a tested recipe: Express, Fastify, Hono, Next.js; for serverless see Serverless.

Terminal window
npm install @watchtower15/sdk
import { WatchTower15 } from '@watchtower15/sdk';
const wt15 = WatchTower15.fromEnvironment({ appInfo: 'billing/2.4.1' });
const me = await wt15.me();
for await (const server of wt15.servers.list({ limit: 100 })) {
console.log(server.name, server.health_status);
}
Credential Variable Used for Created
API key (wt15ak_…) WT15_API_KEY the REST API in the console, under your account’s API keys
Metric source token (wt15ms_…) WT15_METRICS_TOKEN custom metrics when you create a metric source
Log source token (wt15ls_…) WT15_LOGS_TOKEN logs when you create a log source

The SDK checks each credential’s shape locally and refuses one in the wrong slot, naming what it is. On a host that runs the WatchTower15 agent, tailing the log file with the agent is the better log path: the agent reads the file with no code in your application.

  • Node.js. Every Node.js LTS line from 22.12 is supported until its own end of life. Dropping one is a minor release, announced in the release before it.
  • TypeScript. 5.0 and later, under nodenext, bundler and (for a "module": "commonjs" project before TypeScript 6) node10 resolution; ES modules and CommonJS are both published. The declarations name fetch, Response, Headers and AbortSignal, so a project needs @types/node or the DOM lib.
  • Frameworks. NestJS 11 and 12; pino 9 and 10; winston 3; Express 5, Fastify 5, Hono 4 and Next.js 16 as recipes.
  • Versions. Semantic Versioning, independent of the API’s v1: a new API operation is a minor release, a change that breaks the SDK’s own signatures or types a major one, and a generated type’s name never changes. All four packages are released together.
  • Tested. The core on Node 22.12.0 and 26; each integration on 22.12.0 and 26, at its lowest and newest supported framework or logger line; the recipes on Node 24.
  • Other runtimes. Bun, Deno and Cloudflare Workers are expected to work (the core uses fetch and Web Crypto) and are not tested. Browsers are refused unless dangerouslyAllowBrowser is set.
  • Security fixes ship in the newest minor as a patch release at once.