Whatify LogoWhatify

Getting Started

Get started with the Whatify WhatsApp API

This guide will help you get started with the Whatify WhatsApp API.

Prerequisites

  • Node.js 16+ installed
  • An active Whatify account
  • API token from your Whatify dashboard

Installation

Using npm

npm install whatify

Using yarn

yarn add whatify

Using pnpm

pnpm add whatify

Quick Start

1. Get Your API Token

  1. Log in to your Whatify dashboard
  2. Navigate to Settings → API
  3. Create a new API token
  4. Copy the token (you'll need it for the next step)

2. Initialize the Client

Create a new file index.js or index.ts:

import { Whatify } from 'whatify';

const client = new Whatify({
  apiToken: 'your-api-token-here',
});

3. Connect to WhatsApp

async function connectWhatsApp() {
  const result = await client.connect({
    method: 'qrCode'
  });

  if (result.success) {
    console.log('QR Code:', result.qrCode);
    // Display the QR code to scan with WhatsApp
  }
}

connectWhatsApp();

4. Send Your First Message

async function sendMessage() {
  const result = await client.send({
    to: '1234567890',
    text: 'Hello from Whatify!'
  });

  if (result.success) {
    console.log('Message sent successfully!');
  } else {
    console.error('Error:', result.error);
  }
}

sendMessage();

Complete Example

import { Whatify } from 'whatify';

const client = new Whatify({
  apiToken: process.env.WHATIFY_API_TOKEN!,
});

async function main() {
  // Check connection status
  const status = await client.status();
  console.log('Status:', status);

  if (status.status !== 'connected') {
    // Connect if not connected
    const connectResult = await client.connect();
    if (!connectResult.success) {
      console.error('Failed to connect:', connectResult.error);
      return;
    }
    console.log('Connected! QR Code:', connectResult.qrCode);
  }

  // Send a message
  const sendResult = await client.send({
    to: '1234567890',
    text: 'Hello, World!'
  });

  if (sendResult.success) {
    console.log('Message sent!');
  } else {
    console.error('Failed to send:', sendResult.error);
  }
}

main();

Environment Variables

We recommend storing your API credentials in environment variables:

Create a .env file:

WHATIFY_API_TOKEN=your-api-token-here

Then use them in your code:

import { Whatify } from 'whatify';
import * as dotenv from 'dotenv';

dotenv.config();

const client = new Whatify({
  apiToken: process.env.WHATIFY_API_TOKEN!,
});

Next Steps

Common Issues

Rate Limiting

The API has rate limits per endpoint:

  • Connect: 15 requests/minute
  • Status: 20 requests/minute
  • Send: 30 requests/minute
  • Disconnect: 5 requests/minute

Authentication Errors

If you get authentication errors:

  1. Verify your API token is correct
  2. Check if the token has expired
  3. Ensure the token hasn't been revoked

Connection Issues

If you can't connect to WhatsApp:

  1. Make sure you're not already connected on another device
  2. Try using forceNew: true option
  3. Check if your WhatsApp number is valid

Support

For issues and questions: