npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@chatunity/baileytest

v1.4.2

Published

whatsapp api multidevice by ChatUnity

Readme

ChatUnity Baileys

TypeScript & Node.js WhatsApp Web API

Lightweight WhatsApp Web API • No Selenium • WebSocket-based • Multi-device Support

Based on @itsukichann's original work


🎯 Why Baileys?

Baileys connects to WhatsApp Web using WebSockets instead of Selenium/Chromium, saving ~500MB of RAM [web:8]. It supports both multi-device and web versions of WhatsApp with full TypeScript support.

[!IMPORTANT]
The original repository was removed by the main author. Development continues officially in this community-maintained version.

📦 Installation

# Stable version
yarn add @chatunitycenter/baileys

# Edge version (latest features)
yarn add github:chatunitycenter/baileys
import makeWASocket from '@chatunitycenter/baileys'

🚀 Quick Start

import makeWASocket, { useMultiFileAuthState, Browsers } from '@chatunitycenter/baileys'

const { state, saveCreds } = await useMultiFileAuthState('./auth_info_baileys')
const sock = makeWASocket({
    auth: state,
    browser: Browsers.ubuntu('ChatUnity'),
    printQRInTerminal: true
})

sock.ev.on('creds.update', saveCreds)

[!NOTE] Phone number format: country code + number (e.g., 393123456789)

import makeWASocket from '@chatunitycenter/baileys'

const sock = makeWASocket({ printQRInTerminal: false })

if (!sock.authState.creds.registered) {
    const number = '393123456789' // Your number
    const code = await sock.requestPairingCode(number)
    console.log(`Pairing code: ${code}`)
}
const sock = makeWASocket({
    browser: Browsers.macOS('Desktop'),
    syncFullHistory: true
})

⚙️ Configuration

import makeWASocket, { useMultiFileAuthState } from '@chatunitycenter/baileys'

const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
const sock = makeWASocket({ auth: state })

sock.ev.on('creds.update', saveCreds)

Alternative storage methods:

  • useSingleFileAuthState - Single JSON file
  • useMongoFileAuthState - MongoDB storage
import NodeCache from 'node-cache'

const groupCache = new NodeCache({ stdTTL: 5 * 60, useClones: false })

const sock = makeWASocket({
    cachedGroupMetadata: async (jid) => groupCache.get(jid)
})

sock.ev.on('groups.update', async ([event]) => {
    const metadata = await sock.groupMetadata(event.id)
    groupCache.set(event.id, metadata)
})
const sock = makeWASocket({
    markOnlineOnConnect: false
})

🎪 Event Handling

import { Boom } from '@hapi/boom'
import makeWASocket, { DisconnectReason } from '@chatunitycenter/baileys'

async function connectToWhatsApp() {
    const { state, saveCreds } = await useMultiFileAuthState('./auth_info_baileys')
    const sock = makeWASocket({
        auth: state,
        printQRInTerminal: true
    })

    sock.ev.on('connection.update', (update) => {
        const { connection, lastDisconnect } = update
        if(connection === 'close') {
            const shouldReconnect = (lastDisconnect.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut
            if(shouldReconnect) connectToWhatsApp()
        } else if(connection === 'open') {
            console.log('Connected!')
        }
    })

    sock.ev.on('messages.upsert', async ({ messages }) => {
        for (const m of messages) {
            console.log('New message:', m.key.remoteJid)
            await sock.sendMessage(m.key.remoteJid!, { text: 'Hello World!' })
        }
    })

    sock.ev.on('creds.update', saveCreds)
}

connectToWhatsApp()

View all events: BaileysEventMap Documentation

import { makeInMemoryStore, getAggregateVotesInPollMessage } from '@chatunitycenter/baileys'

const store = makeInMemoryStore({})

sock.ev.on("messages.update", async (updates) => {
    for(const { key, update } of updates) {
        if(update.pollUpdates && key.fromMe) {
            const pollCreation = await store.loadMessage(key.remoteJid, key.id)
            if(pollCreation) {
                const pollUpdate = await getAggregateVotesInPollMessage({
                    message: pollCreation.message,
                    pollUpdates: update.pollUpdates,
                })
                console.log('Poll votes:', pollUpdate)
            }
        }
    }
})

💬 Sending Messages

// Simple text
await sock.sendMessage(jid, { text: 'Hello World' })

// With quote
await sock.sendMessage(jid, { text: 'Reply' }, { quoted: message })

// Mention users
await sock.sendMessage(jid, {
    text: '@393123456789',
    mentions: ['[email protected]']
})

// Reaction
await sock.sendMessage(jid, {
    react: { text: '💖', key: message.key }
})

// Location
await sock.sendMessage(jid, {
    location: {
        degreesLatitude: 24.121231,
        degreesLongitude: 55.1121221
    }
})
// Image
await sock.sendMessage(jid, {
    image: { url: './image.png' },
    caption: 'Beautiful image'
})

// Video
await sock.sendMessage(jid, {
    video: { url: './video.mp4' },
    caption: 'Cool video'
})

// Audio (convert to OGG first)
await sock.sendMessage(jid, {
    audio: { url: './audio.ogg' },
    mimetype: 'audio/ogg; codecs=opus'
})

// GIF
await sock.sendMessage(jid, {
    video: fs.readFileSync('gif.mp4'),
    gifPlayback: true
})

// Album (multiple images/videos)
await sock.sendMessage(jid, {
    album: [
        { image: { url: 'img1.jpg' }, caption: 'Photo 1' },
        { video: { url: 'vid1.mp4' }, caption: 'Video 1' }
    ]
})
// Poll
await sock.sendMessage(jid, {
    poll: {
        name: 'Favorite color?',
        values: ['Red', 'Blue', 'Green'],
        selectableCount: 1
    }
})

// Buttons
await sock.sendMessage(jid, {
    text: 'Choose an option',
    footer: 'Powered by ChatUnity',
    buttons: [
        { buttonId: 'id1', buttonText: { displayText: 'Option 1' } },
        { buttonId: 'id2', buttonText: { displayText: 'Option 2' } }
    ]
})

// List
await sock.sendMessage(jid, {
    text: 'Select from menu',
    buttonText: 'View Menu',
    sections: [{
        title: 'Section 1',
        rows: [
            { title: 'Option 1', rowId: 'opt1' },
            { title: 'Option 2', rowId: 'opt2', description: 'Description' }
        ]
    }]
})
// Contact card
const vcard = 'BEGIN:VCARD\nVERSION:3.0\nFN:John Doe\nTEL;type=CELL:+393123456789\nEND:VCARD'
await sock.sendMessage(jid, {
    contacts: {
        displayName: 'John',
        contacts: [{ vcard }]
    }
})

// Forward
await sock.sendMessage(jid, { forward: message, force: true })

// Delete message
await sock.sendMessage(jid, { delete: message.key })

// Edit message
await sock.sendMessage(jid, { edit: message.key, text: 'Edited text' })

🔧 Utility Functions

Message Helpers:

  • getContentType(message) - Get message type
  • downloadMediaMessage(message) - Download media content
  • getDevice(message) - Get sender's device info

Full documentation: Baileys Types

📋 WhatsApp ID Format

  • Personal: [country_code][number]@s.whatsapp.net (e.g., [email protected])
  • Groups: [group_id]@g.us
  • Channels: [channel_id]@newsletter
  • Broadcast: status@broadcast

📚 Additional Resources

⚖️ License & Responsibility

Licensed under MIT License. The developers cannot be held responsible for misuse. Please respect WhatsApp's Terms of Service [web:8].


Credits: Based on the original Baileys library by @itsukichann

Maintained by: ChatUnity Center

Made with ❤️ by the community