waha.js
v0.2.2
Published
TypeScript SDK for WAHA (WhatsApp HTTP API)
Downloads
41
Maintainers
Readme
WAHA.js
A TypeScript SDK for WAHA (WhatsApp HTTP API) that makes it easy to integrate with a WAHA instance.
Installation
# Using npm
npm install waha.js
# Using yarn
yarn add waha.js
# Using bun
bun add waha.jsUsage
import { WahaClient } from 'waha.js';
// Initialize the client
const client = new WahaClient({
baseUrl: 'https://your-waha-instance.com',
apiKey: 'your-api-key', // Optional
});
// Example: Send a text message
async function sendMessage() {
try {
const response = await client.chatting.sendText({
session: 'default',
chatId: '[email protected]',
text: 'Hello from WAHA.js!'
});
console.log('Message sent:', response);
} catch (error) {
console.error('Error sending message:', error);
}
}
// Example: Get QR code for authentication
async function getQRCode() {
try {
const qrCode = await client.auth.getQR({
session: 'default',
format: 'image'
});
console.log('QR Code:', qrCode);
} catch (error) {
console.error('Error getting QR code:', error);
}
}Features
- Full TypeScript support with comprehensive type definitions
- Covers all WAHA API endpoints
- Promise-based API
- Error handling
- Session management
- Authentication
- Messaging
- Group management
- Profile management
- Real-time event handling via WebSockets
- And more...
API Documentation
Client Initialization
const client = new WahaClient({
baseUrl: 'https://your-waha-instance.com', // Required
apiKey: 'your-api-key', // Optional
defaultSession: 'default' // Optional, defaults to 'default'
});Available Modules
auth: Authentication operationssessions: Session managementchatting: Sending messageschats: Chat operationsgroups: Group operationsprofile: Profile managementpresence: Presence operationswebsocket: Real-time event handling via WebSockets
For detailed API documentation, see the API Reference.
License
MIT
Development and Publishing
For information on developing and publishing this package, please see the Development Guide.
