npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@adaptive-ds/waha-client

v0.3.0

Published

TypeScript client and CLI for the WAHA (WhatsApp HTTP API). Full API coverage, Result-typed, Valibot-validated.

Downloads

205

Readme

@adaptive-ds/waha-client

TypeScript client library and CLI for WAHA (WhatsApp HTTP API).

Full endpoint coverage, Result-typed errors, Valibot validation, session defaults, and binary responses as Uint8Array.

Features

  • Full WAHA coverage — sessions, auth (QR / code / passkey), profile, chatting, chats, groups, channels, contacts, lids, labels, presence, status, calls, media convert, events, API keys, apps, storage, server, screenshot
  • Result type — every fallible call returns Result<T> / PromiseResult<T> via @adaptive-ds/result
  • Valibot-validated — request options checked at the edge; no silent any
  • Session defaults — set session once on the client config; override per call
  • Binary as Uint8Array — QR images, screenshots, media files (not raw Response)
  • Library + CLI — import functions or run waha-client from the shell

Install

bun add @adaptive-ds/waha-client

Library

import {
  wahaClientFromEnv,
  wahaClientConfig,
  sessionList,
  authQrGet,
  messageTextSend,
} from "@adaptive-ds/waha-client"

// From env (WAHA_BASE_URL, WAHA_API_KEY, WAHA_SESSION, …)
const fromEnv = wahaClientFromEnv()
if (!fromEnv.success) throw new Error(fromEnv.errorMessage)
const config = fromEnv.data

// Or explicit config
// const cfg = wahaClientConfig({ baseUrl: "http://localhost:3000", apiKey: "…", session: "default" })
// if (!cfg.success) throw new Error(cfg.errorMessage)

const sessions = await sessionList({ config })
if (!sessions.success) throw new Error(sessions.errorMessage)

const qr = await authQrGet({ config }) // Uint8Array PNG by default
if (!qr.success) throw new Error(qr.errorMessage)

const sent = await messageTextSend({
  config,
  chatId: "[email protected]",
  text: "hello",
})
if (!sent.success) throw new Error(sent.errorMessage)

WebSocket events

wahaWebSocketObserve observes one typed WAHA event, then closes the connection. Supply a Valibot payloadSchema so the event payload is validated at runtime. An optional typed predicate runs after validation; returning false ignores that event and keeps observation open. Predicate exceptions return the stable redacted error WebSocket event predicate failed. It uses config.session by default, accepts an explicit session override, and uses config.timeoutMs for cleanup. Await ready before triggering delivery, then await event; call close() to cancel.

import * as a from "valibot"
import { wahaWebSocketObserve } from "@adaptive-ds/waha-client"

const observation = wahaWebSocketObserve({
  config,
  session: "default",
  events: ["message"],
  payloadSchema: a.object({ body: a.string() }),
  predicate: (event) => event.payload.body === "target code",
})
const ready = await observation.ready
if (!ready.success) throw new Error(ready.errorMessage)

const event = await observation.event
if (!event.success) throw new Error(event.errorMessage)
console.log(event.data.payload.body)

Environment

  • WAHA_BASE_URL (required) — WAHA server base URL (e.g. http://localhost:3000)
  • WAHA_API_KEY (optional) — sent as X-Api-Key
  • WAHA_SESSION (optional) — default session name for session-scoped endpoints
  • WAHA_TIMEOUT_MS (optional) — request timeout
  • WAHA_RETRIES (optional) — retry count

Bun loads .env automatically when you run via bun.

CLI

export WAHA_BASE_URL=http://localhost:3000
export WAHA_API_KEY=your-key
export WAHA_SESSION=default

# or: bunx waha-client … / bun run src/cli.ts …
waha-client --help
waha-client version

waha-client sessions list
waha-client sessions get --session default
waha-client sessions create --name default --start
waha-client sessions start|stop|logout|restart|delete|me

waha-client auth qr
waha-client auth request-code --phoneNumber 491701234567

waha-client chats list
waha-client messages send-text --chatId [email protected] --text "hello"
waha-client contacts list
waha-client contacts check-exists --phone 491701234567
waha-client groups list
waha-client groups get --id [email protected]
waha-client server ping|health|version|status
waha-client profile get

Override env per call with --baseUrl, --apiKey, --session.

Stdout is pretty JSON on success. Errors are Result JSON on stderr with exit code 1.

WAHA

Talks to a running WAHA instance. See the WAHA docs for server setup.

License

MIT © David Siewert