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

apipedia.js

v1.0.4

Published

πŸš€ Official Apipedia.js - Complete Node.js library for Apipedia API: WhatsApp, Telegram, SMS, AI Chat with fluent chaining

Readme

πŸš€ Apipedia.js

npm version License: MIT Node.js Version

Official Apipedia.js - The complete Node.js library for Apipedia API with WhatsApp, Telegram, SMS, and AI Chat integration featuring revolutionary fluent chaining.

⭐ Official JavaScript SDK - Built by Apipedia team with revolutionary fluent chaining API!

Installation

npm install apipedia.js

Quick Start

const apipedia = require('apipedia.js');

const client = apipedia('your-appkey', 'your-authkey');

// Send a text message
client.whatsapp('1234567890', 'Hello, World!');

// Send a message with media file path
client.whatsapp('1234567890', 'Check this out!', './path/to/image.jpg');

// Send a message with media URL
client.whatsapp('1234567890', 'Check this out!', 'https://example.com/image.jpg');

// Send a message with media stream
const fs = require('fs');
const media = fs.createReadStream('path/to/image.jpg');
client.whatsapp('1234567890', 'Check this out!', media);

// Send bulk messages (same message to multiple recipients)
client.bulkV1(['628998937095', '6281615677582'], 'Same message to all recipients');

// Send bulk messages (different messages to multiple recipients) 
client.bulkV2(['628998937095', '6281615677582'], ['Message for first', 'Message for second']);

// Send Telegram text message
client.telegramSendMessage('368628054', 'Hello from Telegram Bot!');

// Send Telegram image
client.telegramSendImage('368628054', 'https://example.com/photo.jpg', 'Photo caption');

// Send Telegram location
client.telegramSendLocation('368628054', -6.2088, 106.8456);

// Send Telegram buttons
const buttons = [
  [
    {"text": "Option 1", "callback_data": "option_1"},
    {"text": "Option 2", "callback_data": "option_2"}
  ]
];
client.telegramSendButtons('368628054', 'Choose an option:', buttons);

// Send Telegram document
client.telegramSendDocument('368628054', 'https://temp.apipedia.id/example/sample-1.pdf', 'Document caption', 'document.pdf');

// Use AI Chat
client.aiChat('Hello, how can you help me?', 'b33a2b7b-fd21-41af-92ee-268bcbccce49', 'json');

AI Chat and Telegram Implementation Example

Here's a practical example using environment variables for security:

Using AI Chat with Content Writing Assistant

require('dotenv').config();
const apipedia = require('apipedia.js');

// Initialize with your AI credentials from environment variables
const client = apipedia(
  process.env.APIPEDIA_AI_APPKEY || 'your-ai-appkey-here', 
  process.env.APIPEDIA_AI_AUTHKEY || 'your-ai-authkey-here'
);

async function exampleAIUsage() {
  try {
    // Send a message to the AI Content Writing Assistant
    const response = await client.aiChat(
      'Hello, how can you help me?',
      process.env.APIPEDIA_AI_AGENT_ID || 'b33a2b7b-fd21-41af-92ee-268bcbccce49',
      'json'
    );
    
    console.log('AI Response:', response.getResult());
    
    // Chain: Send the AI response to Telegram
    await response.toTelegram(
      process.env.TEST_TELEGRAM_RECEIVER || '368628054', 
      'AI Response: '
    );
  } catch (error) {
    console.error('Error:', error.message);
  }
}

exampleAIUsage();

Using Telegram with Your Credentials

require('dotenv').config();
const apipedia = require('apipedia.js');

// Initialize with your Telegram credentials from environment variables
const client = apipedia(
  process.env.APIPEDIA_TELEGRAM_APPKEY || 'your-telegram-appkey-here', 
  process.env.APIPEDIA_TELEGRAM_AUTHKEY || 'your-telegram-authkey-here'
);

async function exampleTelegramUsage() {
  try {
    // Send a message via Telegram
    const response = await client.telegramSendMessage(
      process.env.TEST_TELEGRAM_RECEIVER || '368628054', 
      'Hello from Telegram Bot!'
    );
    
    console.log('Telegram Response:', response.getResult());
    
    // Chain: Send the result to WhatsApp
    await response.toWhatsApp(
      process.env.TEST_WHATSAPP_NUMBER || '6281234567890', 
      'Telegram message sent: '
    );
  } catch (error) {
    console.error('Error:', error.message);
  }
}

exampleTelegramUsage();

Additional Examples

For more detailed examples, check out the test files in the tests/ directory:

  • tests/test-ai-implementation.js - Shows how to use AI chat functionality
  • tests/test-telegram-implementation.js - Shows how to use Telegram functionality

You can run these examples with:

node tests/test-ai-implementation.js
node tests/test-telegram-implementation.js

Features

  • WhatsApp Messaging: Send text messages and media attachments (images, documents, etc.)
  • Media Support: Support for file paths, URLs, and streams as media
  • Bulk Messaging: Bulk messaging capabilities (V1 and V2) for WhatsApp
  • Telegram Integration: Complete Telegram bot capabilities (text, images, locations, buttons, documents)
  • SMS Services: Multiple SMS tiers (Regular, VIP, OTP, VVIP)
  • AI Chat Integration: AI-powered chat with customizable agents and response formats
  • Profile Management: Get account profile information
  • Presence Control: Update WhatsApp presence status (typing, online, etc.)
  • Message Tracking: Track message status and delivery receipts
  • Chainable API: Fluent interface for combining operations
  • Cross-platform Forwarding: Forward AI responses to WhatsApp, Telegram, or SMS
  • Environment Configuration: Secure credential management with .env support
  • Comprehensive Error Handling: Detailed error messages for debugging

Documentation

For complete documentation, check out the docs folder:

Methods

WhatsApp Methods

whatsapp(to, message, media = null)

Send a message (with optional media) to a single WhatsApp number.

  • to: Recipient's phone number in international format (e.g., 6281234567890)
  • message: Text message content
  • media (optional): Can be a file path, URL, or stream for media attachments

bulkV1(toNumbers, message)

Send the same message to multiple recipients (Bulk Message V1).

  • toNumbers: Array of phone numbers or pipe-separated string (e.g. '628998937095|6281615677582')
  • message: Text message content to send to all recipients

bulkV2(toNumbers, messages)

Send different messages to multiple recipients (Bulk Message V2).

  • toNumbers: Array of phone numbers or pipe-separated string (e.g. '628998937095|6281615677582')
  • messages: Array of messages or pipe-separated string (e.g. 'message1|message2')

Telegram Methods

telegramSendMessage(receiver, body)

Send a text message to a Telegram chat.

  • receiver: Chat ID of the recipient (e.g., '368628054')
  • body: Text content of the message

telegramSendImage(receiver, imageUrl, caption = '')

Send an image message to a Telegram chat.

  • receiver: Chat ID of the recipient (e.g., '368628054')
  • imageUrl: URL of the image to send
  • caption (optional): Caption text to accompany the image

telegramSendLocation(receiver, latitude, longitude)

Send a location message to a Telegram chat.

  • receiver: Chat ID of the recipient (e.g., '368628054')
  • latitude: Latitude coordinate
  • longitude: Longitude coordinate

telegramSendButtons(receiver, body, buttons)

Send a message with inline keyboard buttons to a Telegram chat.

  • receiver: Chat ID of the recipient (e.g., '368628054')
  • body: Text content of the message
  • buttons: Array of button rows, each containing button objects

telegramSendDocument(receiver, documentUrl, caption = '', filename = '')

Send a document to a Telegram chat.

  • receiver: Chat ID of the recipient (e.g., '368628054')
  • documentUrl: URL of the document to send
  • caption (optional): Caption text to accompany the document
  • filename (optional): Filename to show for the document

SMS Methods

smsRegular(to, msg)

Send a regular SMS message.

  • to: Recipient's phone number in international format
  • msg: SMS message content

smsVIP(to, msg)

Send a VIP SMS message (higher priority).

  • to: Recipient's phone number in international format
  • msg: SMS message content

smsOTP(to, msg)

Send an OTP SMS message.

  • to: Recipient's phone number in international format
  • msg: OTP message content (usually contains verification code)

smsVVIP(to, msg)

Send a VVIP SMS message (highest priority).

  • to: Recipient's phone number in international format
  • msg: SMS message content

AI Chat Methods

aiChat(message, agent_id, format = 'text')

Send a message to AI agent and get response.

  • message: Your message to the AI agent
  • agent_id: ID of the AI agent to use
  • format: Response format ('text' or 'json')

Profile and Status Methods

getProfile()

Get account profile information.

Returns profile data including account details and status.

updatePresence(receiver, presence, duration = null)

Update WhatsApp presence status.

  • receiver: Target phone number
  • presence: Presence type ('composing', 'recording', 'online', etc.)
  • duration (optional): Duration in seconds

Message Status Methods\n#### getMessageStatusAll(messageId)\nGet complete message status information.\n\n- messageId: ID of the message to check\n\n#### getLastStatus(messageId)\nGet the last status of a message.\n\n- messageId: ID of the message to check\n\n#### getLastReceiptStatus(messageId)\nGet the last receipt status of a message.\n\n- messageId: ID of the message to check\n\n### Message Status Examples\n\nThese methods correspond to the following API endpoints:\n\nGet all message statuses:\nbash\ncurl --location --request GET 'https://waconsole.apipedia.id/api/messages/status/all' \\\n --header 'Content-Type: application/json' \\\n --data '{\n \"appkey\":\"Insert your APP Key\",\n \"authkey\":\"Insert your Auth Key\",\n \"message_id\":\"MESSAGE_ID\"\n }'\n\n\nGet last message status:\nbash\ncurl --location --request GET 'https://waconsole.apipedia.id/api/status/last' \\\n --header 'Content-Type: application/json' \\\n --data '{\n \"appkey\":\"Insert your APP Key\",\n \"authkey\":\"Insert your Auth Key\",\n \"message_id\":\"MESSAGE_ID\"\n }'\n\n\nGet last receipt status:\nbash\ncurl --location --request GET 'https://waconsole.apipedia.id/api/messages/status/last/receipt' \\\n --header 'Content-Type: application/json' \\\n --data '{\n \"appkey\":\"Insert your APP Key\",\n \"authkey\":\"Insert your Auth Key\",\n \"message_id\":\"MESSAGE_ID\"\n }'\n

Chainable Cross-Platform Methods

toWhatsApp(to, prefix = '')

Forward the previous result to WhatsApp.

  • to: WhatsApp recipient number
  • prefix (optional): Text to prepend to the message

toTelegram(receiver, prefix = '')

Forward the previous result to Telegram.

  • receiver: Telegram chat ID
  • prefix (optional): Text to prepend to the message

toSMS(to, prefix = '')

Forward the previous result to SMS.

  • to: SMS recipient number
  • prefix (optional): Text to prepend to the message

Advanced Usage Examples

πŸ”— Revolutionary Fluent Chaining

// ✨ NEW! Perfect chaining syntax - exactly what you wanted!
await client
  .aiChat('Generate a motivational quote', 'agent-id', 'text')
  .toWhatsApp('6281234567890', 'πŸ’ͺ Motivation: ')
  .toTelegram('368628054', '⚑ Power up: ')
  .toSMS('6281234567890', 'πŸ“± Daily dose: ');

// πŸš€ Extreme long chains work perfectly!
await client
  .aiChat('Create weather report', 'agent-id')
  .toWhatsApp('6281234567890', '🌀️ WeatherApp: ')
  .toTelegram('368628054', 'β›… TeleWeather: ')
  .toSMS('6281234567890', '🌑️ SMSWeather: ')
  .toWhatsApp('6289876543210', 'πŸ“± Share: ')
  .toTelegram('987654321', 'πŸ’¬ Forward: ');

Chaining Multiple Operations

// Get profile, then send to multiple platforms
await client.getProfile()
             .toWhatsApp('6281234567890', 'My Profile: ')
             .toTelegram('368628054', 'Account Info: ');

// Check message status and forward
await client.getLastStatus('message-id')
             .toSMS('6281234567890', 'Message Status: ');

Presence Management

// Set typing status for 10 seconds
await client.updatePresence('6281234567890', 'composing', 10);

// Set recording status
await client.updatePresence('6281234567890', 'recording');

Environment Variables

For security, credentials should be stored in environment variables rather than hardcoded. Create a .env file in your project root:

# Copy from .env.example and fill in your actual keys
APIPEDIA_APP_KEY=your-app-key-here
APIPEDIA_AUTH_KEY=your-auth-key-here
TEST_WHATSAPP_NUMBER=628998937095
TEST_TELEGRAM_RECEIVER=368628054
AI_AGENT_ID=your-ai-agent-id-here

Then use environment variables in your code:

require('dotenv').config();

const client = apipedia(
  process.env.APIPEDIA_APP_KEY,
  process.env.APIPEDIA_AUTH_KEY
);

πŸ§ͺ Testing

Run All Tests

npm test

Test Comprehensive Chaining

npm run test:comprehensive

This will run extreme long chains to verify that the fluent API works perfectly even with 10+ chained operations!

Test with Coverage

npm run test:coverage

πŸš€ Automatic Publishing

This package supports automatic publishing to npm via GitHub Actions. To set it up:

  1. Create an npm automation token at npm Token Creation
  2. Add the token as a GitHub secret in your repository settings:
    • Go to Settings β†’ Secrets and Variables β†’ Actions
    • Add a new secret named NPM_TOKEN with your npm token as the value
  3. The GitHub Action will automatically publish to npm when changes are pushed to the main branch

The automatic publishing workflow is defined in .github/workflows/npm-publish-semver.yml.

🎯 Perfect Chaining Examples

The library now supports the exact syntax you requested:

// βœ… This works perfectly!
client.aiChat('message').toWhatsApp('123').toTelegram('456').toSMS('789');

// βœ… Even extreme chains work flawlessly!
client
  .aiChat('Create content', 'agent-id')
  .toWhatsApp('111', 'πŸ“± WA: ')
  .toTelegram('222', 'πŸ’¬ TG: ')
  .toSMS('333', 'πŸ“¨ SMS: ')
  .toWhatsApp('444', 'πŸ”„ Share: ')
  .toTelegram('555', '⚑ Forward: ')
  .toSMS('666', 'πŸ“€ Broadcast: ');