Skip to main content
The WSAPI Node.js SDK provides a strongly-typed client for sending WhatsApp messages, managing groups and chats, and receiving real-time events via webhooks or Server-Sent Events (SSE).

Installation

Requirements

  • Node.js 16.0 or later (server environments)
  • Modern browser with Fetch API support (browser environments)
  • Valid WSAPI API key and instance ID

Quick start

Features

  • HTTP Client — strongly-typed client supporting all API operations across messages, groups, chats, and contacts
  • Real-time Events — dual event delivery through webhooks (HTTP POST) or SSE with persistent connections
  • TypeScript Support — complete type safety with comprehensive type definitions
  • Error Handling — both exception-throwing and non-throwing variants for each API method
  • Cross-Platform — compatible with Node.js, browsers, and other JavaScript runtimes

Error handling

The SDK provides two error handling patterns:
Methods throw exceptions on failure. Use standard try/catch:

Receiving events via SSE

Connect to WSAPI’s Server-Sent Events stream to receive real-time events without exposing a public endpoint:

Available operations

Messages

Groups, Chats, Contacts, Session

GitHub

github.com/wsapi-chat/wsapi-node