Home All Docs

Getting Started with Whin API

September 09, 2024

Contents

TL;DR

  • Get your API key from the Whin dashboard
  • Install the SDK with npm install whin-api-sdk
  • Initialize the client with your API key
  • Send your first message in 4 lines of code

Quick Commands

npm install whin-api-sdk
const client = new WhinAPI({ apiKey: 'your-key' });
await client.messages.send({ to: '+1234567890', message: 'Hello!' });

Getting Started with Whin API

Welcome to Whin! This guide will help you get up and running with our WhatsApp API in just a few minutes.

Prerequisites

Before you begin, make sure you have:

  • A valid Whin API account
  • Node.js installed on your system
  • Basic knowledge of REST APIs

Step 1: Get Your API Key

  1. Log in to your Whin dashboard
  2. Navigate to the API section
  3. Generate a new API key
  4. Copy the key and keep it secure

Step 2: Install the SDK

npm install whin-api-sdk

Step 3: Initialize the Client

const WhinAPI = require('whin-api-sdk');

const client = new WhinAPI({
  apiKey: 'your-api-key-here',
  environment: 'production' // or 'sandbox'
});

Step 4: Send Your First Message

async function sendMessage() {
  try {
    const response = await client.messages.send({
      to: '+1234567890',
      message: 'Hello from Whin!',
      type: 'text'
    });
    
    console.log('Message sent:', response);
  } catch (error) {
    console.error('Error:', error);
  }
}

sendMessage();

Next Steps

Need Help?

If you run into any issues, check our FAQ or contact our support team.