Wasend SDK for multiple programming languages
Project description
Wasend SDK
A powerful SDK for managing WhatsApp sessions across multiple programming languages. This SDK provides a simple and intuitive interface for creating, managing, and interacting with WhatsApp sessions.
Features
- Create and manage WhatsApp sessions
- QR code authentication
- Session status management (start, stop, restart)
- Account protection features
- Message logging
- Webhook support
- Multi-language support (TypeScript/JavaScript, Python, Java, .NET, Go)
Installation
TypeScript/JavaScript (npm)
npm install @wasend/core
# or
yarn add @wasend/core
Python (pip)
pip install wasend-dev
Java (Maven)
<dependency>
<groupId>com.wasend</groupId>
<artifactId>wasend-core</artifactId>
<version>1.0.0</version>
</dependency>
.NET (NuGet)
dotnet add package Wasend.Core
Go
go get github.com/wasenddev/wasend-sdk-go
Quick Start
TypeScript/JavaScript Example
import { WasendClient } from '@wasend/core';
// Initialize the client
const client = new WasendClient({
apiKey: 'your-api-key',
baseUrl: 'https://api.wasend.dev'
});
// Create a new session
const session = await client.sessions.createSession({
sessionName: 'my-whatsapp-session',
phoneNumber: '+919876543210', // Example phone number
enableAccountProtection: true,
enableMessageLogging: true,
enableWebhook: false
});
// Get QR code for authentication
const qrCode = await client.sessions.getQRCode(session.uniqueSessionId);
console.log('Scan this QR code with WhatsApp:', qrCode.data);
// Start the session
await client.sessions.startSession(session.uniqueSessionId);
// Get session information
const sessionInfo = await client.sessions.getSessionInfo(session.uniqueSessionId);
console.log('Session status:', sessionInfo.status);
Session Management
Creating a Session
const session = await client.sessions.createSession({
sessionName: 'my-whatsapp-session',
phoneNumber: '+919876543210',
enableAccountProtection: true,
enableMessageLogging: true,
enableWebhook: true,
webhookUrl: 'https://your-webhook-url.com/callback'
});
Session Configuration Options
sessionName: A unique name for your sessionphoneNumber: The WhatsApp phone number to use (format: +[country code][number])enableAccountProtection: Enable additional security featuresenableMessageLogging: Enable message history loggingenableWebhook: Enable webhook notificationswebhookUrl: URL for receiving webhook notifications (required if enableWebhook is true)
Managing Sessions
// Get all sessions
const allSessions = await client.sessions.getAllSessions();
// Get specific session info
const sessionInfo = await client.sessions.getSessionInfo(sessionId);
// Start a session
await client.sessions.startSession(sessionId);
// Stop a session
await client.sessions.stopSession(sessionId);
// Restart a session
await client.sessions.restartSession(sessionId);
// Delete a session
await client.sessions.deleteSession(sessionId);
Authentication
QR Code Authentication
- Create a session
- Get the QR code
- Scan the QR code with WhatsApp on your phone
- The session will automatically connect once scanned
const qrCode = await client.sessions.getQRCode(sessionId);
console.log('QR Code data:', qrCode.data);
Session Status
A session can have the following statuses:
CREATED: Session has been created but not startedSTARTING: Session is in the process of startingCONNECTED: Session is connected and ready to useSTOPPED: Session has been stoppedERROR: Session encountered an error
Webhook Integration
To receive notifications about session events:
- Enable webhooks when creating a session
- Provide a valid webhook URL
- Handle incoming webhook notifications on your server
const session = await client.sessions.createSession({
sessionName: 'webhook-enabled-session',
phoneNumber: '+919876543210',
enableWebhook: true,
webhookUrl: 'https://your-server.com/webhook'
});
Error Handling
try {
const session = await client.sessions.createSession({
sessionName: 'test-session',
phoneNumber: '+919876543210'
});
} catch (error) {
console.error('Error creating session:', error);
}
Best Practices
- Always store the
sessionIdafter creating a session - Implement proper error handling
- Use environment variables for API keys
- Enable account protection for production sessions
- Implement webhook handling for real-time updates
- Regularly check session status
- Clean up unused sessions
Support
For support, please contact:
- Email: admin@wasend.dev
- Website: https://wasend.dev
- Documentation: https://docs.wasend.dev
License
This SDK is licensed under the Apache-2.0 License. See the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wasend-1.0.0.tar.gz.
File metadata
- Download URL: wasend-1.0.0.tar.gz
- Upload date:
- Size: 728.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d03480b009c3d5330e45428066d68bcf56729a8d6bda32b7eb70d0ef202b3a9
|
|
| MD5 |
149dbaba9733eaa3fe0c4e91a3a90046
|
|
| BLAKE2b-256 |
bdcd8b9d695ac150524e252c10a434252a1d7a2527a0351bbc0304aaa4f3f54b
|
File details
Details for the file wasend-1.0.0-py3-none-any.whl.
File metadata
- Download URL: wasend-1.0.0-py3-none-any.whl
- Upload date:
- Size: 726.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c6ef7542a2f61a2afa4e82485de15fa75dbb8d3175dc873b16dff9972a887d9
|
|
| MD5 |
70857572207490c2e910a1d9548f3d16
|
|
| BLAKE2b-256 |
ca79d33ce93da273c7c8efe3741f2bf0801562da35f4bd8860b9031dd57a0bb9
|