Socketon

WhatsApp API for Node.js

Install Documentation
100K+
Downloads
500+
Methods
1.8.26
Version
MIT
License

Install

bash
npm install socketon
Requirements: Node.js >= 20.0.0

Quick Start

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

async function start() {
    const { state, saveCreds } = await useMultiFileAuthState('./auth');
    
    const sock = makeWASocket({
        logger: pino({ level: 'silent' }),
        auth: state,
        printQRInTerminal: true
    });

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

    sock.ev.on('messages.upsert', async ({ messages }) => {
        const msg = messages[0];
        if (!msg.key.fromMe && msg.message) {
            console.log('Message:', msg.message.conversation || msg.message.extendedTextMessage?.text);
        }
    });

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

start();

Features

Messages

  • Send text, image, video, audio
  • Send document, sticker
  • Buttons, list, template
  • React, reply, forward

Groups

  • Create, leave, delete
  • Add/remove participants
  • Promote/demote admin
  • Invite link management

Newsletter

  • Create newsletter
  • Follow/unfollow
  • Send message
  • Auto react

Profile

  • Update name, picture
  • Privacy settings
  • Block/unblock
  • Business profile

Media

  • Upload to server
  • Download message
  • Link preview
  • Thumbnail generation

Calls

  • Make call
  • Reject call
  • Handle incoming

Developer

Ibra Decode

Ibra Decode

Creator & Maintainer

Full-stack developer with expertise in WhatsApp API, Node.js, and automation. Building Socketon since 2024.