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

@kyyinfinite/baileys

v2.1.0

Published

WhatsApp Web library for Node.js with the Kyyinfinite Simple API

Readme

@kyyinfinite/baileys

A developer-friendly WhatsApp messaging API for Node.js with a fluent builder interface, message utilities, JID helpers, interactive messages, media handling, and advanced message composition.

Installation

npm install @kyyinfinite/baileys

Quick Start

import { makeWASocket, attachKyyinfinite } from '@kyyinfinite/baileys'

const sock = makeWASocket(config)

attachKyyinfinite(sock)

await sock
  .text('Hello')
  .send(jid)

The API is designed to keep common operations short while still allowing advanced message builders when needed.


API

Text

await sock
  .text('Hello')
  .send(jid)

Additional text options:

await sock
  .text('Hello')
  .footer('Kyyinfinite')
  .mentions(['[email protected]'])
  .send(jid)

Available text builder methods:

text()
footer()
context()
mentions()
viewOnce()
edit()
payload()
build()
send()

Media

Shortcut builders:

await sock.image('./image.jpg')
  .caption('Image')
  .send(jid)

await sock.video('./video.mp4')
  .caption('Video')
  .send(jid)

await sock.audio('./audio.mp3')
  .send(jid)

await sock.voice('./voice.ogg')
  .send(jid)

await sock.document('./file.pdf')
  .fileName('document.pdf')
  .send(jid)

await sock.sticker('./sticker.webp')
  .send(jid)

Other media shortcuts:

ptv()
gif()

Universal Media

Use one builder when the media type needs to be selected dynamically:

await sock
  .media(buffer)
  .asImage()
  .caption('Photo')
  .send(jid)

Supported types:

asImage()
asVideo()
asAudio()
asDocument()
asSticker()

Media builder options include:

caption()
fileName()
mimetype()
context()
mentions()
payload()
viewOnce()
ptt()
voice()
ptv()
videoNote()
gif()
animated()
dimensions()
thumbnail()
build()
send()

Unified Send

For simple messages, use:

await sock.send(jid, 'Hello')

Object payloads are also supported:

await sock.send(jid, {
  text: 'Hello'
})

Media:

await sock.send(jid, {
  image: './image.jpg',
  caption: 'Hello'
})

The unified API is intended for cases where you do not need to manually create a builder.


Quoted Messages

Reply directly to an existing message:

await sock.reply(message, 'Hello')

Or:

await sock.quoted(message, 'Hello')

Message wrapper:

const m = sock.wrapMessage(message)

await m.reply('Hello')

Available message actions:

reply()
react()
edit()
delete()
forward()
download()

Socket shortcuts:

reply()
reactTo()
editMessage()
deleteMessage()
forwardMessage()
downloadMessage()

Message Parser

Parse an incoming message into a simple object:

const parsed = sock.parseMessage(message, {
  prefix: '.'
})

console.log(parsed.text)
console.log(parsed.command)
console.log(parsed.args)

Returned data includes:

message
content
messageType
text
command
args
jid
sender
isGroup
isReply
quoted
key

Example command:

.menu game hard

can be consumed as:

parsed.command // "menu"
parsed.args    // ["game", "hard"]

Mentions

Text containing a WhatsApp-style number can be resolved automatically:

await sock.send(
  jid,
  'Hello @628123456789'
)

Disable automatic mention resolution when required:

await sock.send(
  jid,
  'Hello @628123456789',
  {
    autoMentions: false
  }
)

Explicit mentions can also be supplied through the builder API.


JID Utilities

Parse a JID:

sock.parseJid('628123456789:[email protected]')

Result:

{
  user: '628123456789',
  device: '7',
  server: 's.whatsapp.net',
  jid: '628123456789:[email protected]'
}

Access individual parts:

sock.jidUser(jid)
sock.jidServer(jid)
sock.jidDevice(jid)

Normalize:

sock.jid(jid)

Create a JID:

sock.makeJid('628123456789')

JID checks:

sock.isGroup(jid)
sock.isPrivate(jid)
sock.isBroadcast(jid)
sock.isStatus(jid)
sock.isNewsletter(jid)
sock.isLid(jid)

Buttons

Basic Button

await sock
  .button()
  .title('Menu')
  .body('Choose an option')
  .addButton('Option 1', 'one')
  .addButton('Option 2', 'two')
  .send(jid)

Reply

sock.button()
  .reply('Open', 'open')

Aliases:

reply()
quickReply()

URL

sock.button()
  .url('Website', 'https://example.com')

Copy

sock.button()
  .copy('Copy Code', 'KYY-001')

Both aliases are supported:

copy()
coppy()
ctaCopy()

Call

sock.button()
  .call('Call', '628123456789')

Aliases:

call()
ctaCall()

Other button helpers:

reminder()
cancelReminder()
address()
location()
select()
section()
row()
image()
document()
media()
context()
payload()
clear()
params()

ButtonV2

await sock
  .buttonV2()
  .addButton(...)
  .send(jid)

The builder also supports:

addButton()
addRawButton()
setRawThumbnail()
setThumbnail()
setMedia()
loadFrom()
build()
send()

Carousel

Create multiple cards:

await sock
  .carousel()
  .body('Choose a product')
  .footer('Kyyinfinite')

  .card()
    .image(image1)
    .title('Product One')
    .body('Product description')
    .button('Pilih', 'product_1')
    .url('Website', 'https://example.com')
    .copy('Code', 'KYY-001')
    .call('Call', '628123456789')
    .add()

  .card()
    .image(image2)
    .title('Product Two')
    .body('Another product')
    .button('Pilih', 'product_2')
    .add()

  .send(jid)

Carousel methods:

card()
addCard()
cards()
clear()
title()
subtitle()
body()
text()
footer()
context()
payload()
loadFrom()
build()
send()

Card methods:

title()
body()
text()
footer()
image()
video()
media()
button()
reply()
quickReply()
url()
copy()
coppy()
call()
buttons()
rawButton()
context()
payload()
build()
add()
end()

Rich Messages

The advanced rich-message builder is available through:

await sock
  .ai()
  .title('Example')
  .text('Rich message')
  .code('console.log("Hello")')
  .send(jid)

The rich builder supports composition features such as:

text
FOA text
code
table
source
reels
image
video
product
post
metadata
tip
HTML
widget
footer action
suggestion
section
submessage

It also provides message/node management:

delete()
assignId()
hasId()
getIds()
peek()
loadFrom()
build()
buildEdit()
send()
sendEdit()

FOAD

await sock
  .foad()
  .addTitle('Example')
  .addHtml('<p>Hello</p>')
  .addTab(...)
  .send(jid)

Available operations include:

setResponseId()
refreshResponseId()
setBotResponseId()
refreshBotResponseId()
addTitle()
setPreviewTitle()
addHtml()
addTab()
clearTabs()
buildResponse()
build()
send()
sendEdit()

FOAD2

await sock
  .foad2()
  ...

FOAD2 is exposed as a separate builder for its own response/composition workflow.


createKyyinfinite

If you do not want to augment the socket directly:

const api = createKyyinfinite(sock)

await api.text('Hello').send(jid)

This creates a facade without replacing the socket.


attachKyyinfinite

For direct socket helpers:

attachKyyinfinite(sock)

await sock.text('Hello').send(jid)

The augmentation is additive. Existing socket methods are not intentionally replaced when their names already exist.


API Overview

Messaging
├── text()
├── send()
├── quoted()
├── reply()
├── wrapMessage()
├── parseMessage()
└── message actions

Media
├── media()
├── image()
├── video()
├── audio()
├── voice()
├── document()
├── sticker()
├── ptv()
└── gif()

JID
├── jid()
├── parseJid()
├── jidUser()
├── jidServer()
├── jidDevice()
├── makeJid()
├── isGroup()
├── isPrivate()
├── isBroadcast()
├── isStatus()
├── isNewsletter()
└── isLid()

Interactive
├── button()
├── buttonV2()
└── carousel()

Advanced
├── ai()
├── foad()
└── foad2()

Design Goals

The API is built around a few principles:

  • short syntax for common operations;
  • chainable builders;
  • reusable message utilities;
  • simple JID handling;
  • flexible media input;
  • advanced builders remain available;
  • existing low-level access stays usable;
  • no duplicate connection layer;
  • builders keep isolated state.

The main idea is:

Simple when you need it.
Advanced when you want it.

TypeScript

Type declarations are included with the package.

import { attachKyyinfinite } from '@kyyinfinite/baileys'

The Simple API declarations cover the builder and convenience APIs exposed by the package.


Version

Current release:

@kyyinfinite/baileys 2.1.0

What's new in 2.1.0

+ Unified send()
+ Quoted/reply helpers
+ KyyMessage
+ Message parser
+ Universal media builder
+ JID parser and utilities
+ JID classifiers
+ makeJid()
+ Automatic mention handling
+ Additional message shortcuts
+ Expanded Simple API declarations

Roadmap

Planned improvements:

  • Native Baileys API compatibility
  • More message shortcuts
  • More media utilities
  • Additional TypeScript improvements
  • Expanded integration tests
  • API documentation expansion

Repository

urlGitHub Repositoryhttps://github.com/kyyinfinite/baileys

License

MIT