API DOC NodeJS

API
Jul 31, 2024 7 mins read

WANotif - API Doc Node.JS

Node.JS

Sending Text Message

Required variables

  • client_id = Your Client ID CLICK HERE
  • mobile = WhatsApp Number
  • text = Text To Send
  • API KEYS = Your API Key CLICK HERE
const fetch = require('node-fetch');

  async function sendTextMessage() {
    const url = 'https://uhuy.net/api/user/v2/send_message'; // Replace with your domain endpoint
  
    const body = {
      client_id: 'CLIENT_ID', // Client ID here
      mobile: '919999999999',
      text: 'Hello world',
    };
  
    const token = 'YOUR_API_KEYS'; // Your API keys here
  
    const headers = {
      'Content-Type': 'application/json',
      Authorization: `Bearer ${token}`,
    };
  
    try {
      const response = await fetch(url, {
        method: 'POST',
        headers,
        body: JSON.stringify(body),
      });
  
      if (!response.ok) {
        throw new Error('Request failed');
      }
  
      const data = await response.json();
      console.log(data); // Handle the response data as per your requirements
    } catch (error) {
      console.error(error);
    }
  }
  
  sendTextMessage();

Sending Template Message

Required variables 

  • client_id
  • mobile 
  • templet_id 
  • API KEYS
const fetch = require('node-fetch');

async function sendTextMessage() {
  const url = 'https://uhuy.net/api/user/v2/send_templet'; // Replace with your domain endpoint

  const body = {
    client_id: 'CLIENT_ID', // Client ID here
    mobile: '919999999999',
    templet_id: 1, // Your templet ID
  };

  const token = 'YOUR_API_KEYS'; // Your API keys here

  const headers = {
    'Content-Type': 'application/json',
    Authorization: `Bearer ${token}`,
  };

  try {
    const response = await fetch(url, {
      method: 'POST',
      headers,
      body: JSON.stringify(body),
    });

    if (!response.ok) {
      throw new Error('Request failed');
    }

    const data = await response.json();
    console.log(data); // Handle the response data as per your requirements
  } catch (error) {
    console.error(error);
  }
}
sendTextMessage();

Successful Response

{
  "success": true,
  "message": "The message has been successfully sent.",
  "data": {}
}