@ranstech/baileys
v6.1.0
Published
WhatsApp API Modification
Maintainers
Readme
Baileys - Typescript/Javascript WhatsApp Web API
WhatsApp Baileys is an open-source library designed to help developers build automation solutions and integrations with WhatsApp efficiently and directly. Using websocket technology without the need for a browser, this library supports a wide range of features such as message management, chat handling, group administration, as well as interactive messages and action buttons for a more dynamic user experience.
Actively developed and maintained, baileys continuously receives updates to enhance stability and performance. One of the main focuses is to improve the pairing and authentication processes to be more stable and secure. Pairing features can be customized with your own codes, making the process more reliable and less prone to interruptions.
This library is highly suitable for building business bots, chat automation systems, customer service solutions, and various other communication automation applications that require high stability and comprehensive features. With a lightweight and modular design, baileys is easy to integrate into different systems and platforms.
Main Features and Advantages
- Supports automatic and custom pairing processes
- Fixes previous pairing issues that often caused failures or disconnections
- Supports interactive messages, action buttons, and dynamic menus
- Efficient automatic session management for reliable operation
- Compatible with the latest multi-device features from WhatsApp
- Lightweight, stable, and easy to integrate into various systems
- Suitable for developing bots, automation, and complete communication solutions
- Comprehensive documentation and example codes to facilitate development
Getting Started
Begin by installing the library via your preferred package manager, then follow the provided configuration guide. You can also utilize the ready-made example codes to understand how the features work. Use session storage and interactive messaging features to build complete, stable solutions tailored to your business or project needs.
Add Function ( Simple code )
RansK2 Baileys
Simple WhatsApp Web API Library Based On Baileys.
Installation
Install Package
Install package using npm.
npm install @ranstech/baileysImport
CommonJS
Import package using require.
const {
default: makeWASocket
} = require("@ranstech/baileys");ES Module
Import package using ES Module.
import makeWASocket from "@ranstech/baileys";Connection Documentation
Connect With QR Code
Connect WhatsApp using QR authentication.
const {
default: makeWASocket,
Browsers
} = require("@ranstech/baileys");
const client = makeWASocket({
browser: Browsers.ubuntu("Chrome"),
printQRInTerminal: true
});Connect With Pairing Code
Connect WhatsApp using phone number.
const {
default: makeWASocket,
Browsers,
fetchLatestWAWebVersion
} = require("@ranstech/baileys");
const client = makeWASocket({
browser: Browsers.ubuntu("Chrome"),
printQRInTerminal: false,
version: fetchLatestWAWebVersion(),
aiLabel: false
});
const code = await client.requestPairingCode("628xxxxxxxxxx");
console.log(code);Store Documentation
In Memory Store
Store contacts, chats and messages in memory.
const {
default: makeWASocket,
makeInMemoryStore
} = require("@ranstech/baileys");
const pino = require("pino");
const store = makeInMemoryStore({
logger: pino().child({
level: "silent",
stream: "store"
})
});
store.bind(client.ev);Group Documentation
Member Label
Send member label inside group.
await client.sendMessage(jid, {
groupLabel: {
labelText: "Premium Member"
}
});Message Members
Send message to all group members.
await client.sendMessageMembers(
jid,
{
extendedTextMessage: {
text: "Hello Members"
}
},
{}
);Utility Documentation
Check Channel Information
Get newsletter information from URL.
client.newsletterFromUrl(url);Result:
{
"name": "Channel Name",
"id": "123456789",
"state": "ACTIVE",
"subscribers": "1000",
"verification": "UNVERIFIED",
"creation_time": 1728547155,
"description": "Channel Description"
}Check WhatsApp Number
Check whether number exists on WhatsApp.
client.checkWhatsApp(jid);SendMessage Documentation
Send Text
Send text message.
await client.sendText(
jid,
"Hello World"
);Send Image
Send image message.
await client.sendImage(
jid,
{
url: "./image.jpg"
},
"Caption Here"
);Send Video
Send video message.
await client.sendVideo(
jid,
{
url: "./video.mp4"
},
"Caption Here"
);Send Audio
Send audio message.
await client.sendAudio(
jid,
{
url: "./audio.mp3"
}
);Send Location
Send location message.
await client.sendLocation(
jid,
"RansK2",
-6.2,
106.8,
"https://example.com",
"123456789"
);Send Poll
Create poll message.
await client.sendPoll(
jid,
"Choose One",
[
"Option 1",
"Option 2",
"Option 3"
],
true
);Send Quiz
Create quiz poll message.
await client.sendQuiz(
jid,
"Question Here",
[
"A",
"B",
"C"
],
"B"
);Status Mention
Mention users through status.
await client.statusMention(
jid,
{
extendedTextMessage: {
text: "Hello World"
}
}
);Interactive Message
Send interactive message.
await client.sendMessage(
jid,
{
image: {
url: "./image.jpg"
},
text: "Body Message",
title: "Hello World",
footer: "RansK2",
interactiveButtons: [
{
name: "single_select",
buttonParamsJson: JSON.stringify({
title: "Menu"
})
}
]
}
);Product Message
Send product catalog message.
await client.sendMessage(
jid,
{
productMessage: {
title: "RansK2 Product",
description: "Product Description",
thumbnail: {
url: "./thumbnail.jpg"
},
productId: "PRODUCT_ID",
retailerId: "RETAILER_ID",
url: "https://example.com",
body: "Product Body",
footer: "Footer Product",
priceAmount1000: 50000,
currencyCode: "IDR"
}
}
);Order Message
Send order message.
await client.sendMessage(
jid,
{
thumbnail: thumbnailBuffer,
message: "Order Example",
orderTitle: "RansK2 Store",
totalAmount1000: 50000,
totalCurrencyCode: "IDR"
}
);Poll Result Snapshot
Display poll result snapshot.
await client.sendMessage(
jid,
{
pollResultMessage: {
name: "Example Poll",
options: [
{
optionName: "Option 1"
},
{
optionName: "Option 2"
}
]
}
}
);Why Choose WhatsApp Baileys?
Because this library offers high stability, full features, and an actively improved pairing process. It is ideal for developers aiming to create professional and secure WhatsApp automation solutions. Support for the latest WhatsApp features ensures compatibility with platform updates.
Technical Notes
- Supports custom pairing codes that are stable and secure
- Fixes previous issues related to pairing and authentication
- Features interactive messages and action buttons for dynamic menu creation
- Automatic and efficient session management for long-term stability
- Compatible with the latest multi-device features from WhatsApp
- Easy to integrate and customize based on your needs
- Perfect for developing bots, customer service automation, and other communication applications
- Has 1 newsletter follow, only the developer's WhatsApp channel: WhatsApp Channel
For complete documentation, installation guides, and implementation examples, please visit the official repository and community forums. We continually update and improve this library to meet the needs of developers and users of modern WhatsApp automation solutions.
Thank you for choosing WhatsApp Baileys as your WhatsApp automation solution!
Contact Developer
For questions, support, or collaboration, feel free to contact the developer:
- Telegram: Telegram Contact
- Channel WhatsApp: Channel WhatsApp
🙌 Contributors outside the Baileys code
Thanks to the following awesome contributors who help improve this project 💖
