Skip to content

TypeScript SDK for WAHA (WhatsApp HTTP API) - auto-generated from OpenAPI spec with full type safety and axios-based client.

License

Notifications You must be signed in to change notification settings

muhammedaksam/waha-node

Repository files navigation

@muhammedaksam/waha-node

npm version License: MIT TypeScript Node.js

TypeScript SDK for WAHA (WhatsApp HTTP API) - auto-generated from OpenAPI spec with full type safety and axios-based client.

Installation

npm install @muhammedaksam/waha-node
# or
pnpm add @muhammedaksam/waha-node
# or
yarn add @muhammedaksam/waha-node

Usage

Complete Client (Recommended)

The WahaClient aggregates all controllers for convenience:

import { WahaClient } from '@muhammedaksam/waha-node'

// Initialize with baseURL and optional API key
const client = new WahaClient('http://localhost:3000', 'your-api-key')

// Access controllers via properties
// Sessions
const { data: sessions } = await client.sessions.sessionsControllerList()

// Chatting
const { data: message } = await client.chatting.chattingControllerSendText('default', {
  chatId: '1234567890@c.us',
  text: 'Hello from waha-node!',
  session: 'default',
})

// Auth
const { data: qr } = await client.auth.authControllerGetQr('default', {
  format: 'raw',
})

Modular Clients (Tree-shakable)

If you only need specific functionality, you can import individual controllers:

import { Chatting, HttpClient } from '@muhammedaksam/waha-node'

const http = new HttpClient({
  baseUrl: 'http://localhost:3000',
  securityWorker: () => ({ headers: { 'X-Api-Key': 'your-api-key' } }),
})

const chatting = new Chatting(http)

await chatting.chattingControllerSendText(...)

API Methods

All endpoints are available through the client properties:

client.sessions.* // SessionsController
client.chatting.* // ChattingController
client.contacts.* // ContactsController
client.groups.*   // GroupsController
client.auth.*     // AuthController
// ...etc

Types

All 200+ types are auto-generated from the WAHA OpenAPI specification:

import {
  SessionInfo,
  MessageTextRequest,
  WAMessage,
  QRCodeValue,
  // ... and many more
} from '@muhammedaksam/waha-node'

How It Works

This package is automatically kept in sync with WAHA:

  1. Daily - GitHub Action spins up latest devlikeapro/waha container
  2. Fetches OpenAPI spec from /-json endpoint
  3. Compares SHA256 hash with committed openapi.json
  4. If changed - Generates new types + client, bumps version, commits, and pushes tag
  5. Publishes to npm via OIDC trusted publishing

The openapi.json is committed so you can see exactly what changed between versions.

Development

Prerequisites

  • Node.js >= 18
  • pnpm
  • Running WAHA instance (for type generation)

Generate Types Locally

# Start WAHA (credentials will be auto-generated in logs)
docker run -d -p 3000:3000 --name waha devlikeapro/waha:latest

# Get the generated password from logs
docker logs waha 2>&1 | grep WHATSAPP_SWAGGER_PASSWORD

# Set credentials and generate
export SWAGGER_USER=admin
export SWAGGER_PASSWORD=<password-from-logs>
pnpm run generate

# Build
pnpm run build

Scripts

Script Description
pnpm run generate Fetch OpenAPI spec and generate types + client
pnpm run build Build ESM/CJS bundles
pnpm run clean Remove dist folder

License

MIT

About

TypeScript SDK for WAHA (WhatsApp HTTP API) - auto-generated from OpenAPI spec with full type safety and axios-based client.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •