Documentation
This guide reflects Baileys (UDMODZ Edition), published under the package amiudmodz.
Baileys is a WhatsApp Web API automation TypeScript library. This project doesn't control WhatsApp using an automated browser, but instead uses WhatsApp Web's WebSocket-based protocol to interact with WhatsApp servers directly.
If you don't use TypeScript or JavaScript, it is recommended to learn them before using this library.
Baileys does not use the WhatsApp Business API (WABA). Rather it connects to a personal or a business (mobile app) account using the Linked Devices feature.
Yes, this means that this project is in no way affiliated with or endorsed by WhatsApp. Use at your own discretion. Do not spam people with this. We discourage any stalkerware, bulk or automated messaging usage.
Installationโ
Adding Baileys UDMODZ Edition to your project is as simple as:
- npm
- Yarn
- pnpm
npm install amiudmodz
yarn add amiudmodz
pnpm add amiudmodz
As of now, Baileys requires Node 20+ to function.
Since NPM/Yarn releases are on a semi-monthly basis, you can use the GitHub branch directly
Synopsisโ
The main export of the Baileys library (and the default one) is the makeWASocket function.
This export returns an object full of socket-related functions. You can use these to interact with WhatsApp.
The socket is also an extension of an EventEmitter. You can listen to the events it emits to collect and store data. Baileys is asynchronous and event-based.
The socket authenticates with WhatsApp Web using the "Auth state", that you provide in the config.
For this guide, we'll be using the useMultiFileAuthState to create this auth state.
The auth state should be implemented from scratch, taking the built-in useMultiFileAuthState function as an inspiration. DO NOT rely on it in prod! It is very inefficient and is purely for demo purposes.
Next, we'll be learning in specific about the Socket type, and how to use its functions!