Whatsapp Api Js

Whatsapp Api Js: A lightweight, dependency-less, efficient TS library for interacting with the official WhatsApp Cloud API

Last verified:

Visit Whatsapp Api Js

What is Whatsapp Api Js?

Whatsapp Api Js is whatsapp-api-js is a TypeScript server-agnostic framework for building bots and applications using the official WhatsApp Business API (Cloud API). It is version 6.2.1 and is designed to work across any runtime including Node.js, Deno, Bun, and browser environments. The library provides a clean, typed interface to send and receive all WhatsApp message types including text, images, documents, videos, audio, voice notes, contacts, locations, templates, interactive messages, and reactions.

Key features include full TypeScript typing for type safety, built-in webhook handling with GET and POST handlers for Meta app authentication, event emitters for message and sent events, and middleware support for simplifying setup across different frameworks like Deno. The library supports all message types from the official WhatsApp API including text, media (image, video, document, audio, voice notes, sticker), contacts, locations, templates, interactive buttons and list messages, and reactions. It includes event handlers like Whatsapp.on.message for receiving messages and Whatsapp.on.sent for tracking sent messages, plus a markAsRead function.

This tool is for developers building WhatsApp bots, customer support automation, business messaging applications, and any integration requiring the official WhatsApp Business API. It is ideal for TypeScript/JavaScript developers who want a well-typed, framework-agnostic library with active maintenance (111 releases as of November 2025) and strong community adoption (299 stars, 108 users).

Whatsapp Api Js pricing

Pricing model: Freemium

whatsapp-api-js is a free open-source library under MIT license with no paid plans or subscription. It is installed via npm (npm install whatsapp-api-js) at no cost. However, using the WhatsApp Business API requires a Meta Business App, and Meta charges based on per-message pricing for the WhatsApp Business Platform. Meta charges when messages are delivered (not sent), based on who the message is sent to and the message category (marketing, utility, authentication, service). Service messages are free, and utility messages sent in response to user messages are also free. There are volume tiers for utility and authentication messages. The 72-hour session from user-initiated conversations (ads, Facebook page CTAs) is also free.

Whatsapp Api Js pros

  • Fully typed TypeScript library for type safety
  • Server-agnostic - works with Node.js, Deno, Bun, browsers
  • Official WhatsApp Business API (Cloud API) framework
  • Supports all message types: text, media, contacts, locations, templates, interactive, reactions
  • Built-in webhook GET and POST handlers for Meta authentication
  • Event emitters for on.message and on.sent events
  • Middleware support simplifies framework setup (Deno, etc.)
  • markAsRead function to mark messages as read
  • Active maintenance with 111 releases as of Nov 2025
  • Open source under MIT license
  • 299 GitHub stars and 108 users adopting it
  • Easy npm installation: npm install whatsapp-api-js
  • Simple import syntax for WhatsAppAPI and message types
  • Includes examples folder with tutorials for all message types
  • Supports both temporary and permanent API tokens

Whatsapp Api Js cons

  • Requires Meta Business App with WhatsApp API activated first
  • Must set up webhook URL at Meta dashboard manually
  • Requires API token and app secret configuration
  • Beta releases are 110% likely to break compatibility
  • No built-in database or persistence layer
  • Does not handle conversation 24-hour window limitations
  • Requires understanding of WhatsApp Business API pricing from Meta
  • Webhook verify token must be configured separately

Frequently asked questions about Whatsapp Api Js

What is whatsapp-api-js?

whatsapp-api-js is a TypeScript server-agnostic framework for the official WhatsApp Business API (Cloud API). It allows developers to build WhatsApp bots and messaging applications that work across any runtime including Node.js, Deno, Bun, and browsers. The library is fully typed and supports all WhatsApp message types.

What do I need before using whatsapp-api-js?

You need a Meta Business App with WhatsApp API activated. You must get an API token (temporary or permanent) and your App Secret from the dashboard at App Settings > Basic > App Secret. You also need to set up a webhook URL at your Meta app under WhatsApp > Settings and subscribe to the messages event.

How do I handle incoming messages?

Set up an event handler using Whatsapp.on.message which receives an object with phoneID, from, message, name, and reply function. You can check message.type (text, image, document, etc.) and respond using the reply function. The library also provides Whatsapp.markAsRead(phoneID, message.id) to mark messages as read.

How do I handle webhook authentication?

The package includes a GET handler for webhook authentication. Configure webhookVerifyToken when creating WhatsAppAPI instance, then call Whatsapp.get(e.query) on GET requests. For POST requests, use Whatsapp.post() with the parsed data, raw body, and x-hub-signature-256 header.

What is the middleware module for?

The middleware module (whatsapp-api-js/middleware/deno) simplifies the setup process of WhatsAppAPI for different frameworks like Deno. It provides handle_post and handle_get methods that make it easier to integrate with framework-specific request handling [web:].

Is whatsapp-api-js free to use?

Yes, whatsapp-api-js is completely free and open-source under the MIT license. There are no paid plans for the library itself. However, Meta charges for WhatsApp Business Platform messages based on per-message pricing for non-service categories.

How do I track sent messages?

Use the Whatsapp.on.sent event emitter which receives an object with phoneID, to, and message. This fires whenever your bot sends a message, allowing you to log or track message delivery.

Where can I find examples and documentation?

Full documentation is at whatsappapijs.web.app. Previous versions are archived at secreto311226.github.io/whatsapp-api-js. The GitHub repository includes an examples folder with tutorials on creating each message type and using basic library methods. Types are available via importing /types or /emitters files.

Categories

Use cases

Browse all AI tools on NeedAnAI