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 🙏

© 2025 – Pkg Stats / Ryan Hefner

socketon

v0.31.0

Published

WhatsApp API Library - Socketon By IbraDecode

Readme

Socketon WhatsApp API Library


Why Socketon?

If you feel Baileys is now slow, has double responses, or sometimes infinite connecting, Socketon can be a better alternative.

This is a fork of Baileys focused on stability, session handling, and more flexible pairing codes. Most APIs remain the same, so migration from Baileys usually doesn't require major changes.


Key Features

  • Custom Pairing Codes: Default "SOCKETON" code for easier authentication
  • Enhanced Stability: Improved session handling and automatic reconnection
  • Multi-Device Support: Full compatibility with WhatsApp's multi-device feature
  • Interactive Messages: Buttons, lists, and native flow interactions
  • Album Messages: Send multiple images in a single message
  • Newsletter Integration: Auto-follow and manual newsletter management
  • Business Messaging: Product catalogs, payments, and business features
  • Media Support: Comprehensive upload/download with progress tracking
  • Event-Driven Architecture: Extensive real-time event system
  • TypeScript Support: Full type definitions for better development experience
  • Lightweight & Fast: WebSocket-based, no browser dependencies

Installation

npm install socketon

Requirements:

  • Node.js >= 20.0.0

Quick Start

Basic Echo Bot

const { makeWASocket, useMultiFileAuthState } = require('socketon');

async function startBot() {
  // Setup authentication
  const { state, saveCreds } = await useMultiFileAuthState('./auth');

  // Create WhatsApp socket
  const sock = makeWASocket({
    auth: state,
    printQRInTerminal: true
  });

  // Handle connection
  sock.ev.on('connection.update', (update) => {
    const { connection, qr } = update;

    if (qr) console.log('Scan QR Code:', qr);
    if (connection === 'open') console.log('Connected to WhatsApp!');
  });

  // Handle messages
  sock.ev.on('messages.upsert', async ({ messages }) => {
    for (const msg of messages) {
      if (msg.key.fromMe) continue;

      const jid = msg.key.remoteJid;
      const text = msg.message?.conversation || msg.message?.extendedTextMessage?.text || '';

      console.log(`Message from ${jid}: ${text}`);

      // Echo response
      if (text) {
        await sock.sendMessage(jid, { text: `Echo: ${text}` });
      }
    }
  });

  // Save credentials
  sock.ev.on('creds.update', saveCreds);
}

startBot().catch(console.error);

Pairing Code Authentication

const { makeWASocket, useMultiFileAuthState } = require('socketon');

async function startWithPairing() {
  const { state, saveCreds } = await useMultiFileAuthState('./auth');

  const sock = makeWASocket({
    auth: state,
    printQRInTerminal: false // Disable QR, use pairing code
  });

  sock.ev.on('connection.update', async (update) => {
    const { connection } = update;

    if (connection === 'open') {
      // Use default "SOCKETON" pairing code
      const pairingCode = await sock.requestPairingCode('6281234567890');
      console.log('Pairing Code:', pairingCode);

      // Or use custom pairing code
      // const customCode = await sock.requestPairingCode('6281234567890', 'MYCODE');
      // console.log('Custom Pairing Code:', customCode);
    }
  });

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

startWithPairing().catch(console.error);

Documentation

Complete Guide

For comprehensive documentation covering everything from basic to advanced usage:

Read the Complete Guide

The complete guide includes:

  • Detailed installation and setup
  • Authentication methods (QR code, pairing code)
  • Message handling (text, media, interactive)
  • Group management and newsletter features
  • Business API integration and webhooks
  • Event system and error handling
  • Advanced usage patterns and performance optimization
  • Database integration and real-world use cases
  • Deployment guides and troubleshooting
  • API reference and migration guide

Examples Directory

Check the examples/ directory for runnable code samples:

  • Basic Bot: Simple echo bot with command handling
  • Media Handling: Download/upload images, videos, documents
  • Group Management: Admin bot for group control
  • Business Features: Product catalog and ordering system
  • Analytics: Bot with usage statistics and monitoring
  • Deployment: Production-ready setup with Docker/PM2

Use Cases

Socketon is perfect for building:

  • Chatbots: Customer service, entertainment, automation
  • Business Applications: CRM integration, order management
  • Automation Tools: Message forwarding, scheduling
  • Analytics Bots: Message tracking, user engagement
  • Fun Bots: Games, quizzes, interactive experiences
  • E-commerce: Product catalogs, order processing

Migration from Baileys

Migrating from Baileys is usually simple, just change the import:

// From Baileys
const { makeWASocket } = require('@whiskeysockets/baileys');

// To Socketon
const { makeWASocket } = require('socketon');

For detailed migration steps, see the Migration Guide in the complete documentation.


Troubleshooting

Common Issues

Connection Problems:

  • Check internet connection
  • Ensure WhatsApp account is active
  • Try deleting auth/ folder and re-authenticating

Authentication Issues:

  • Delete auth folder and scan QR again
  • Check file permissions on auth directory
  • Ensure stable network during authentication

Message Failures:

  • Verify JID format
  • Check if recipient blocked you
  • Implement retry logic for reliability

For detailed troubleshooting, see COMPLETE_GUIDE.md#troubleshooting.


Contributing

We welcome contributions! Please see our Contributing Guide for details.

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.


Credits


Support & Community


Ready to build your WhatsApp bot? Start with the Quick Start above, or explore the complete documentation for advanced features!

Version Management

See VERSION_MANAGEMENT.md for detailed versioning and release information.

Socketon v0.31.0 - Built by IbraDecode