Skip to main content

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 session
  • phoneNumber: The WhatsApp phone number to use (format: +[country code][number])
  • enableAccountProtection: Enable additional security features
  • enableMessageLogging: Enable message history logging
  • enableWebhook: Enable webhook notifications
  • webhookUrl: 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

  1. Create a session
  2. Get the QR code
  3. Scan the QR code with WhatsApp on your phone
  4. 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 started
  • STARTING: Session is in the process of starting
  • CONNECTED: Session is connected and ready to use
  • STOPPED: Session has been stopped
  • ERROR: Session encountered an error

Webhook Integration

To receive notifications about session events:

  1. Enable webhooks when creating a session
  2. Provide a valid webhook URL
  3. 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

  1. Always store the sessionId after creating a session
  2. Implement proper error handling
  3. Use environment variables for API keys
  4. Enable account protection for production sessions
  5. Implement webhook handling for real-time updates
  6. Regularly check session status
  7. Clean up unused sessions

Support

For support, please contact:

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

wasend-1.0.0.tar.gz (728.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wasend-1.0.0-py3-none-any.whl (726.1 kB view details)

Uploaded Python 3

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

Hashes for wasend-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7d03480b009c3d5330e45428066d68bcf56729a8d6bda32b7eb70d0ef202b3a9
MD5 149dbaba9733eaa3fe0c4e91a3a90046
BLAKE2b-256 bdcd8b9d695ac150524e252c10a434252a1d7a2527a0351bbc0304aaa4f3f54b

See more details on using hashes here.

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

Hashes for wasend-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1c6ef7542a2f61a2afa4e82485de15fa75dbb8d3175dc873b16dff9972a887d9
MD5 70857572207490c2e910a1d9548f3d16
BLAKE2b-256 ca79d33ce93da273c7c8efe3741f2bf0801562da35f4bd8860b9031dd57a0bb9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page