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

arattai-web.js

v1.0.1

Published

A Arattai API client that operates via the Arattai Web browser app

Downloads

7

Readme

arattai-web.js

A Arattai API client library for Node.js that connects through the Arattai Web browser app.

Installation

npm install arattai-web.js

Note: Node.js v18 or higher is required.

Quick Start

const { Client } = require('arattai-web.js');

const client = new Client();

client.on('qr', (qr) => {
    console.log('QR RECEIVED', qr);
});

client.on('ready', () => {
    console.log('Client is ready!');
});

client.on('message_sent', (message) => {
    console.log('Message sent:', message);
});

client.initialize();

Features

  • QR Code Authentication - Scan QR code with your Arattai mobile app
  • Session Persistence - Saves sessions to avoid repeated QR scans
  • Send Messages - Send text messages to chats
  • Get Chats - Retrieve list of all chats
  • Event-Driven - Uses events for better code organization
  • TypeScript Support - Includes TypeScript definitions

Usage

Basic Example

const { Client } = require('arattai-web.js');

const client = new Client({
    sessionPath: './.wwebjs_auth',
    headless: false
});

client.on('qr', (qr) => {
    // Display QR code to user
    console.log('Scan this QR code:', qr);
});

client.on('ready', async () => {
    console.log('Client is ready!');
    
    // Get all chats
    const chats = await client.getChats();
    console.log('Chats:', chats);
    
    // Send a message
    if (chats.length > 0) {
        await client.sendMessage(chats[0].id, 'Hello, Arattai!');
    }
});

client.initialize();

Advanced Example

const { Client } = require('arattai-web.js');

const client = new Client({
    sessionPath: './.wwebjs_auth',
    headless: true, // Run in headless mode
    qrRefreshInterval: 20000 // Refresh QR every 20 seconds
});

// Listen for loading screen updates
client.on('loading_screen', (percent, message) => {
    console.log(`Loading: ${percent}% - ${message}`);
});

// Listen for QR code
client.on('qr', (qr) => {
    // Save QR code to file or display in UI
    saveQRCodeToFile(qr);
});

// Listen for authentication
client.on('authenticated', () => {
    console.log('Authenticated successfully!');
});

// Listen for ready event
client.on('ready', async () => {
    console.log('Client is ready!');
    
    // Get chats
    const chats = await client.getChats();
    
    // Send message to first chat
    if (chats.length > 0) {
        const result = await client.sendMessage(chats[0].id, 'Hello!');
        console.log('Message sent:', result);
    }
});

// Handle errors
client.on('error', (error) => {
    console.error('Error:', error);
});

// Initialize
client.initialize();

API Reference

Client

Constructor Options

{
  sessionPath: string,        // Path to save session (default: './.wwebjs_auth')
  headless: boolean,          // Run browser in headless mode (default: true)
  userDataDir: string,        // Custom user data directory
  qrRefreshInterval: number   // QR refresh interval in ms (default: 20000)
}

Events

  • qr - Emitted when QR code is generated

    client.on('qr', (qrCode) => {
      // qrCode is a base64 data URL
    });
  • ready - Emitted when client is authenticated and ready

    client.on('ready', () => {
      // Client is ready to use
    });
  • authenticated - Emitted when authentication is successful

    client.on('authenticated', () => {
      // User is authenticated
    });
  • loading_screen - Emitted during loading process

    client.on('loading_screen', (percent, message) => {
      console.log(`${percent}% - ${message}`);
    });
  • message_sent - Emitted when a message is sent

    client.on('message_sent', (message) => {
      console.log('Sent to', message.chatId);
    });
  • disconnected - Emitted when client disconnects

  • error - Emitted on errors

Methods

  • initialize() - Initialize the client and connect to web.arattai.in
  • sendMessage(chatId, content, options) - Send a message to a chat
  • getChats() - Get list of all chats
  • getChatById(chatId) - Get a specific chat by ID
  • logout() - Logout and clear session
  • destroy() - Close browser and cleanup

Examples

See example.js for a complete working example.

Session Management

Sessions are automatically saved to avoid repeated QR scans:

const client = new Client({
  sessionPath: './.wwebjs_auth'
});

// First run: QR code will be shown
// Subsequent runs: Session will be restored automatically
client.initialize();

Troubleshooting

QR Code Not Appearing

  1. Check if web.arattai.in is accessible
  2. Try running with headless: false to see what's happening
  3. Check browser console for errors
  4. Verify Puppeteer can launch Chrome

Session Not Restoring

  1. Check if session file exists at sessionPath
  2. Verify file permissions
  3. Try deleting session file and re-authenticating

Browser Issues

  1. Ensure Puppeteer can download Chromium
  2. Check system dependencies
  3. Try running with headless: false for debugging

TypeScript Support

The library includes TypeScript definitions:

import { Client } from 'arattai-web.js';

const client = new Client({
  sessionPath: './.wwebjs_auth'
});

client.on('ready', async () => {
  const chats = await client.getChats();
  // chats is typed as ChatInfo[]
});

Security Considerations

  1. Session Files: Protect session files - they contain authentication data
  2. Headless Mode: Use headless mode in production
  3. Error Handling: Implement proper error handling
  4. Rate Limiting: Implement rate limiting to avoid being blocked

License

Apache-2.0 License

Disclaimer

This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with Arattai or any of its subsidiaries or affiliates. Use at your own risk.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

References

Inspired by whatsapp-web.js