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 whatifyUsing yarn
yarn add whatifyUsing pnpm
pnpm add whatifyQuick Start
1. Get Your API Token
- Log in to your Whatify dashboard
- Navigate to Settings → API
- Create a new API token
- 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-hereThen 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
- API Reference - Complete API documentation
- Examples - More usage examples
- Manual Testing - Test API endpoints manually
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:
- Verify your API token is correct
- Check if the token has expired
- Ensure the token hasn't been revoked
Connection Issues
If you can't connect to WhatsApp:
- Make sure you're not already connected on another device
- Try using
forceNew: trueoption - Check if your WhatsApp number is valid
Support
For issues and questions:
- GitHub Issues: Report an issue
- Email: [email protected]