
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
whatshub-sdk
Advanced tools
TypeScript/JavaScript SDK for integrating with the WhatsHub WhatsApp API. Send messages, manage instances, and interact with WhatsApp programmatically.
npm install whatshub-sdk
# or
yarn add whatshub-sdk
import { WhatsHubClient } from 'whatshub-sdk';
const client = new WhatsHubClient({
baseUrl: 'http://localhost:9697',
apiToken: 'your-api-token-here'
});
// Check server health
const health = await client.getStatus();
console.log('Server status:', health);
// Send a text message
const message = await client.messages.sendText({
from: '971582354842',
to: '971521128878',
text: 'Hello from WhatsHub SDK!'
});
import { WhatsHubClient } from 'whatshub-sdk';
const client = new WhatsHubClient({
baseUrl: 'http://localhost:9697',
apiToken: 'your-api-token-here',
timeout: 30000 // optional, default is 30000ms
});
const instance = await client.instances.create({
phoneNumber: '971582354842'
});
console.log('QR Code:', instance.qrCodeUrl);
const status = await client.instances.getStatus('971582354842');
console.log('Instance status:', status.state);
const instances = await client.instances.list();
console.log('Total instances:', instances.instances.length);
const result = await client.instances.reconnect('971582354842');
console.log('Reconnected:', result.success);
await client.instances.delete('971582354842', {
logout: true // optional: logout before deleting
});
await client.messages.sendText({
from: '971582354842',
to: '971521128878',
text: 'Hello from WhatsHub!'
});
await client.messages.sendImage({
from: '971582354842',
to: '971521128878',
imageUrl: 'https://example.com/image.jpg',
caption: 'Check out this image!' // optional
});
await client.messages.sendDocument({
from: '971582354842',
to: '971521128878',
documentUrl: 'https://example.com/document.pdf',
filename: 'report.pdf', // optional
caption: 'Monthly report' // optional
});
await client.messages.sendVideo({
from: '971582354842',
to: '971521128878',
videoUrl: 'https://example.com/video.mp4',
caption: 'Watch this!' // optional
});
import { validatePhoneNumber, normalizePhoneNumber } from 'whatshub-sdk';
// Validate phone number
if (validatePhoneNumber('971582354842')) {
console.log('Valid phone number');
}
// Normalize phone number (removes spaces, dashes, etc.)
const normalized = normalizePhoneNumber('+971 58 235 4842');
console.log(normalized); // '971582354842'
import { WhatsHubClient, ApiError } from 'whatshub-sdk';
try {
await client.messages.sendText({
from: '971582354842',
to: '971521128878',
text: 'Hello!'
});
} catch (error) {
if (error instanceof ApiError) {
console.error('API Error:', error.message);
console.error('Status Code:', error.statusCode);
console.error('Response:', error.response);
}
}
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
baseUrl | string | Yes | - | Base URL of the WhatsHub API server |
apiToken | string | Yes | - | API authentication token |
timeout | number | No | 30000 | Request timeout in milliseconds |
client.instances.create(request) - Create a new WhatsApp instanceclient.instances.getStatus(phoneNumber) - Get instance statusclient.instances.list() - List all instancesclient.instances.reconnect(phoneNumber) - Reconnect an instanceclient.instances.delete(phoneNumber, options?) - Delete an instanceclient.messages.sendText(request) - Send text messageclient.messages.sendImage(request) - Send image messageclient.messages.sendDocument(request) - Send document messageclient.messages.sendVideo(request) - Send video messageclient.getStatus() - Get server health statusyarn install
yarn build
yarn test
yarn dev
yarn typecheck
MIT
FAQs
API integration SDK for WhatsHub
We found that whatshub-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.