npm package: @muhammedaksam/waha-node
Description: Node.js TypeScript SDK for WAHA (WhatsApp HTTP API) - auto-generated from OpenAPI spec
Author: Muhammed Mustafa AKŞAM
Latest version: 2026.3.4

# @muhammedaksam/waha-node

[![npm version](https://img.shields.io/npm/v/@muhammedaksam/waha-node.svg)](https://www.npmjs.com/package/@muhammedaksam/waha-node)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
[![Node.js](https://img.shields.io/badge/Node.js-18%2B-green.svg)](https://nodejs.org/)

TypeScript SDK for [WAHA (WhatsApp HTTP API)](https://github.com/devlikeapro/waha) - auto-generated from OpenAPI spec with full type safety and axios-based client.

## Installation

```bash
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:

```typescript
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:

```typescript
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:

```typescript
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:

```typescript
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

```bash
# 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