whatsapp-web.js README

The project's README from github.com/wwebjs/whatsapp-web.js. As one markdown file: README.md.

WWebJS Website

npm NPM Downloads GitHub contributors Depfu Discord server

About

whatsapp‑web.js is a powerful Node.js library that lets you interact with WhatsApp Web, making it easy to build a dynamic WhatsApp API with nearly all features of the web client. It uses Puppeteer to access WhatsApp Web’s internal functions and runs them in a managed browser instance to reduce the risk of being blocked.

Installation

Node.js v18.0.0 or higher, is required.

npm install whatsapp-web.js
yarn add whatsapp-web.js
pnpm add whatsapp-web.js

Having trouble installing? Take a peak at the Guide for more detailed instructions.

Example usage

const { Client } = require('whatsapp-web.js');
const qrcode = require('qrcode-terminal');

const client = new Client();

client.on('qr', (qr) => {
    qrcode.generate(qr, { small: true });
});

client.on('ready', () => {
    console.log('Client is ready!');
});

client.on('message', (msg) => {
    if (msg.body == '!ping') {
        msg.reply('pong');
    }
});

client.initialize();

Take a look at example.js for additional examples and use cases.
For more details on saving and restoring sessions, check out the Authentication Strategies.

Supported features

Feature Status
Multi Device ✅
Send messages ✅
Receive messages ✅
Send media (images/audio/documents) ✅
Send media (video) ✅ (requires Google Chrome)
Send stickers ✅
Receive media (images/audio/video/documents) ✅
Send contact cards ✅
Send location ✅
Send buttons ❌ (DEPRECATED)
Send lists ❌ (DEPRECATED)
Receive location ✅
Message replies ✅
Join groups by invite ✅
Get invite for group ✅
Modify group info (subject, description) ✅
Modify group settings (send messages, edit info) ✅
Add group participants ✅
Kick group participants ✅
Promote/demote group participants ✅
Mention users ✅
Mention groups ✅
Mute/unmute chats ✅
Block/unblock contacts ✅
Get contact info ✅
Get profile pictures ✅
Set user status message ✅
React to messages ✅
Create polls ✅
Channels ✅
Vote in polls ✅
Communities 🔜

Something missing? Make an issue and let us know!

Supporting the project

You can support the maintainer of this project through the links below:

Contributing

Feel free to open pull requests; we welcome contributions! However, for significant changes, it's best to open an issue beforehand. Make sure to review our contribution guidelines before creating a pull request. Before creating your own issue or pull request, always check to see if one already exists!

Disclaimer

This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries or its affiliates. The official WhatsApp website can be found at whatsapp.com. "WhatsApp" as well as related names, marks, emblems and images are registered trademarks of their respective owners. Also it is not guaranteed you will not be blocked by using this method. WhatsApp does not allow bots or unofficial clients on their platform, so this shouldn't be considered totally safe.

License

Copyright 2019 Pedro S Lopez

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this project except in compliance with the License.
You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

whatsapp-web.js (wwebjs/whatsapp-web.js)

Searching Database…

这是做什么的?它是一个 Node.js 的 WhatsApp 客户端库:你的代码通过操作 WhatsApp Web 来搭建一个 WhatsApp API,几乎具备网页版客户端的全部功能。
所以它不是 WhatsApp 官方 API——那它到底是怎么工作的?它是在 Node.js 代码里使用的库,不是独立的应用。底层通过 Puppeteer 驱动真实的 WhatsApp Web 客户端,运行在一个托管管理的浏览器实例中。
怎么把它加到我的项目里?在 Node.js v18+ 的项目里执行 'npm install whatsapp-web.js' 安装这个包,然后从 example.js 开始上手;README 里有入门指南和完整文档的链接。
运行之前我需要装好哪些东西?需要 Node.js v18.0.0 或更高版本。这个包会自动带上 Puppeteer 以及 fluent-ffmpeg、node-webpmux 之类的媒体处理工具,另外发送视频还需要安装 Google Chrome。
用它的话,我的账号被封号的可能性大吗?风险确实存在:这是非官方客户端,而 WhatsApp 不允许在平台上使用机器人,所以你的号码可能会被封,项目本身也无法保证安全。
它能跑在什么地方——需要特定的操作系统吗?它是一个 Node.js 库,所以只要能运行 Node 18+ 和 Chrome/Chromium 的系统都可以——Windows、macOS 或 Linux 都行。没有移动版:它控制的是 WhatsApp Web 会话,不是手机上的应用。
我还能发送交互式按钮或列表消息吗?不能——功能表里这两项都标着 ❌(已弃用),所以只能用普通消息、媒体、贴纸、投票和表情回应。
发送视频需要什么特别的条件吗?是的——功能表里注明,发送视频媒体需要安装 Google Chrome。
它支持 WhatsApp 社群(Communities)吗?暂时不支持——社群功能标注为即将推出(🔜),而频道、投票和常规的群组管理已经可以用了。
Creator
wwebjs
Size
6.3 MB
Stars
22.7K
Age
7y
Commits · 90 Days