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

@saazkira/baileys

v2.1.5

Published

Baileys is a lightweight JavaScript library for interacting with the WhatsApp Web API using WebSocket.

Readme

📚 Table of Contents

✨ What's Different

This fork (S44ZKIRA Baileys) extends the original Baileys with several custom patches:

| Feature | Description | |---------|-------------| | 🤖 Code Block Message | Send syntax-highlighted code blocks via { code, language } — rendered as AI bot messages in WhatsApp | | 🪪 Custom Message ID | All outgoing message IDs prefixed with S44ZKIRA instead of the default | | 🐛 LID Bug Fixes | Full fix for participant, mentionedJid, sender, and group admin LID resolution | | 📦 makeInMemoryStore Fix | Corrected store behavior for stable session handling | | 📣 Newsletter Support | Full channel/newsletter create, follow, react, and admin management | | 🤖 AI Logo Message | Support for AI bot avatar in message context | | 📊 Logger Buffer Clear | Prevents memory buildup from log buffers | | 👥 LID → JID Conversion | Auto-converts LID mentions, sender LID, and group member LID to JID |

🌟 Features

  • Multi-Device Support
  • 🔄 Real-Time Messaging (text, media, polls, buttons, code blocks)
  • 🛠️ Group & Channel Management (create, modify, invite)
  • 🔒 End-to-End Encryption
  • 📦 Session Persistence
  • 🤖 Rich Message Types (code blocks, interactive, carousels)

⚡ Contact Admin

📜 License

  • This project is licensed for personal and non-commercial use only.
  • Redistribution, modification, or renaming for personal purposes is allowed.
  • Commercial use, resale, or name-hunting is strictly prohibited.

🤝 Contribution Guidelines

We welcome contributions to improve this project. To contribute:

  1. Fork the repository
  2. Create a new branch for your feature or fix
  3. Submit a pull request with a clear explanation of the changes

All contributions will be reviewed before merging.

📥 Installation

npm install @saazkira/baileys
# or
yarn add @saazkira/baileys

🚀 Quick Start

const {
  default: makeWASocket,
  useMultiFileAuthState,
} = require('@saazkira/baileys');

const {
  state,
  saveCreds
} = await useMultiFileAuthState("./path/to/sessions/folder")

const sock = makeWASocket({
  printQRInTerminal: true,
  auth: state
})

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

sock.ev.on('messages.upsert', ({ messages }) => {
  console.log('New message:', messages[0].message);
});

📖 Documentation

🔌 Connecting Account

const sock = makeWASocket({
  printQRInTerminal: true, // true to display QR Code
  auth: state
})
const sock = makeWASocket({
  printQRInTerminal: false,
  auth: state
})

if (!sock.authState.creds.registered) {
  const number = "62xxxx"

  // default pairing code
  const code = await sock.requestPairingCode(number)

  // custom 8-digit pairing code
  const customCode = "S44ZKIRA"
  const code = await sock.requestPairingCode(number, customCode)
  console.log(code)
}

📡 Handling Events

sock.ev.on('messages.upsert', ({ messages }) => {
  console.log('New message:', messages[0].message);
});
sock.ev.on('messages.update', (m) => {
  if (m.pollUpdates) console.log('Poll vote:', m.pollUpdates);
});

📨 Sending Messages

/**
 * @param {string} jid - Recipient JID (WhatsApp ID or group)
 * @param {Object} content - Message content
 * @param {Object} [options] - Options: quoted, ephemeral, etc.
 */
sock.sendMessage(jid, content, options)
// Simple Text
await sock.sendMessage(jid, { text: 'Hello!' });

// With Quoted Reply
await sock.sendMessage(jid, { text: 'Hello!' }, { quoted: message });

// With link preview
await sock.sendMessage(jid, {
  text: 'Visit https://example.com',
  linkPreview: {
    'canonical-url': 'https://example.com',
    title: 'Example Domain',
    description: 'A demo website',
    jpegThumbnail: fs.readFileSync('preview.jpg')
  }
});

Renders as a syntax-highlighted code block in WhatsApp (AI bot style).

// JavaScript code block
await sock.sendMessage(jid, {
  code: 'console.log("Hello World")',
  language: 'javascript'
}, { quoted: message });

// Python code block
await sock.sendMessage(jid, {
  code: 'print("Hello World")',
  language: 'python'
}, { quoted: message });

// Bash / terminal output
await sock.sendMessage(jid, {
  code: stderr.trim(),
  language: 'bash'
}, { quoted: message });

Supported languages:

| Language | Key | |----------|-----| | JavaScript | javascript, js | | TypeScript | typescript, ts | | Python | python, py | | Bash/Shell | bash, sh, zsh | | Go | go, golang | | Rust | rust, rs | | C | c, h | | C++ | cpp, c++ | | C# | csharp, cs | | CSS | css | | HTML | html | | PowerShell | powershell, ps1 | | CMD | cmd, bat |

// With local file buffer
await sock.sendMessage(jid, { 
  image: fs.readFileSync('image.jpg'),
  caption: 'My cat!',
  mentions: ['[email protected]']
});

// With URL
await sock.sendMessage(jid, { 
  image: { url: 'https://example.com/image.jpg' },
  caption: 'Downloaded image'
});
// With Local File
await sock.sendMessage(jid, { 
  video: fs.readFileSync('video.mp4'),
  caption: 'Funny clip!'
});

// View Once
await sock.sendMessage(jid, {
  video: fs.readFileSync('secret.mp4'),
  viewOnce: true
});
// Regular audio
await sock.sendMessage(jid, { 
  audio: fs.readFileSync('audio.mp3'),
  ptt: false
});

// Push-to-talk voice note
await sock.sendMessage(jid, { 
  audio: fs.readFileSync('voice.ogg'),
  ptt: true,
  waveform: [0, 1, 0, 1, 0]
});
const vcard = 'BEGIN:VCARD\n'
  + 'VERSION:3.0\n' 
  + 'FN:Jeff Singh\n'
  + 'ORG:Ashoka Uni\n'
  + 'TELtype=CELLtype=VOICEwaid=911234567890:+91 12345 67890\n'
  + 'END:VCARD'

await sock.sendMessage(jid, { 
  contacts: { 
    displayName: 'Your Name', 
    contacts: [{ vcard }] 
  }
})
await sock.sendMessage(jid, {
  react: {
    text: '👍', // empty string to remove
    key: message.key
  }
})

| Time | Seconds | |------|---------| | 24h | 86400 | | 7d | 604800 | | 30d | 2592000 |

// Pin
await sock.sendMessage(jid, {
  pin: { type: 1, time: 86400, key: message.key }
})

// Keep
await sock.sendMessage(jid, {
  keep: { key: message.key, type: 1 }
})
// Static
await sock.sendMessage(jid, {
  location: {
    degreesLatitude: 37.422,
    degreesLongitude: -122.084,
    name: 'Google HQ'
  }
});

// Live location
await sock.sendMessage(jid, {
  location: {
    degreesLatitude: 37.422,
    degreesLongitude: -122.084,
    accuracyInMeters: 10
  },
  live: true,
  caption: "I'm here!"
});
await sock.sendMessage(jid, {
  call: { name: 'Call message', type: 1 } // 2 for video
})
await sock.sendMessage(jid, {
  poll: {
    name: 'Favorite color?',
    values: ['Red', 'Blue', 'Green'],
    selectableCount: 1
  }
});
await sock.sendAlbumMessage(jid,
  [
    { image: { url: 'https://example.com/image.jpg' }, caption: 'Hello World' },
    { video: { url: 'https://example.com/video.mp4' }, caption: 'Hello World' }
  ],
  { quoted: message, delay: 3000 }
)
await sock.sendMessage(jid, {
  groupInvite: {
    jid: '[email protected]',
    name: 'Group Name!', 
    caption: 'Invitation To Join My Whatsapp Group',
    code: 'xYz3yAtf...',
    expiration: 86400,
    jpegThumbnail: fs.readFileSync('preview.jpg')
  }
})
await sock.sendMessage(jid, {      
  text: 'Here is body message',
  title: 'Here is title', 
  subtitle: 'Here is subtitle', 
  footer: '© S44ZKIRA Baileys',
  viewOnce: true,
  shop: {
    surface: 1,
    id: 'facebook_store_name'
  }
})
const native_flow_button = [{
  name: 'quick_reply',
  buttonParamsJson: JSON.stringify({
    display_text: 'Quick Reply',
    id: '123'
  })
}]

await sock.sendMessage(jid, {
  text: 'Choose:',
  title: 'Title',
  footer: '© S44ZKIRA Baileys',
  interactive: native_flow_button
})
await sock.sendMessage(jid, {
  text: 'Here is body message',
  title: 'Here is title', 
  footer: '© S44ZKIRA Baileys',
  cards: [{
    image: { url: 'https://www.example.com/image.jpg' },
    title: 'Card title',
    body: 'Card body',
    footer: '© S44ZKIRA',
    buttons: [{
      name: 'quick_reply',
      buttonParamsJson: JSON.stringify({ display_text: 'Select', id: '123' })
    }]
  }]
})
await sock.sendMessage(jid, {
  text: 'Menu:',
  sections: [
    { title: 'Food', rows: [
      { title: 'Pizza', rowId: 'pizza' },
      { title: 'Burger', rowId: 'burger' }
    ]}
  ],
  buttonText: 'Browse'
});

📣 Newsletter

const newsletter = await sock.newsletterMetadata("invite", "0029Vaf0HPMLdQeZsp3XRp2T")
// or by jid
const newsletter = await sock.newsletterMetadata("jid", "120363282083849178@newsletter")
await sock.newsletterFollow("120363282083849178@newsletter")
await sock.newsletterUnfollow("120363282083849178@newsletter")
await sock.newsletterMute("120363282083849178@newsletter")
await sock.newsletterUnmute("120363282083849178@newsletter")
const newsletter = await sock.newsletterCreate(
  "Newsletter Name",
  "Description here",
  { url: 'https://example.com/image.jpg' }
)
await sock.newsletterReactMessage("120363282083849178@newsletter", "12", "🦖")

🛠️ Groups

const group = await sock.groupCreate("Group Title", ["[email protected]"]);
await sock.groupSettingUpdate(jid, 'announcement')   // only admins send
await sock.groupSettingUpdate(jid, 'not_announcement') // everyone send
await sock.groupSettingUpdate(jid, 'locked')           // only admins edit info
await sock.groupSettingUpdate(jid, 'unlocked')         // everyone edit info
await sock.groupParticipantsUpdate(jid, ['[email protected]'], 'add')
await sock.groupParticipantsUpdate(jid, ['[email protected]'], 'remove')
await sock.groupParticipantsUpdate(jid, ['[email protected]'], 'promote')
await sock.groupParticipantsUpdate(jid, ['[email protected]'], 'demote')
const code = await sock.groupInviteCode(jid)
console.log('https://chat.whatsapp.com/' + code)

// Revoke
const newCode = await sock.groupRevokeInvite(jid)
const metadata = await sock.groupMetadata(jid)
console.log(metadata.subject, metadata.desc)

🔒 Privacy

await sock.updateProfilePicture(jid, { url: 'https://example.com/image.jpg' })
await sock.removeProfilePicture(jid)
await sock.updateBlockStatus(jid, 'block')
await sock.updateBlockStatus(jid, 'unblock')
await sock.updateLastSeenPrivacy("all")         // or "contacts", "none"
await sock.updateOnlinePrivacy("all")           // or "match_last_seen"
await sock.updateProfilePicturePrivacy("all")   // or "contacts", "none"
await sock.updateReadReceiptsPrivacy("all")     // or "none"
await sock.updateGroupsAddPrivacy("all")        // or "contacts"
await sock.updateDefaultDisappearingMode(86400) // 0 to disable

⚙️ Advanced

const sock = makeWASocket({ logger: { level: 'debug' } });
sock.ws.on('CB:presence', (json) => console.log(json));
sock.ws.on('CB:edge_routing', (node) => console.log(node));

⚠️ Disclaimer

This project is not affiliated with WhatsApp/Meta. Use at your own risk.
Refer to WhatsApp's Terms for compliance.

🔗 Full Documentation

Explore all features in the Baileys GitHub Wiki