Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kavenegar-api

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kavenegar-api

kavenegar sms provider api

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
decreased by-85.25%
Maintainers
1
Weekly downloads
 
Created
Source

Kavenegar Node.js API Module

A zero-dependency TypeScript/JavaScript module for interacting with the Kavenegar API, allowing you to send SMS messages, manage message status, and perform other actions.

Installation

npm install --save kavenegar-api

Usage

Initialization

Replace 'YOUR_API_KEY' with your actual API key.

import { KavenegarApi } from 'kavenegar-api';
// OR
const { KavenegarApi } = require('kavenegar-api');

// Initialize the Kavenegar API with your API key
const apiKey = 'YOUR_API_KEY' || 0 // set apiKey to zero just for test connection;
const kavenegar = new KavenegarApi({ apiKey });

Get Current Date for testing connection

async function testConnection() {
    const date = await kavenegar.getDate();
    console.log('Connection successful. Current date:', date.datetime);
}

Send a Single SMS

async function sendSingleSMS() {
    const message = 'Hello, world!';
    const receptor = 'RECIPIENT_NUMBER';
    const result = await kavenegar.send({ message, receptor });
    console.log('Single SMS sent:', result);
}

Send Multiple SMS Messages

async function sendMultipleSMS() {
    const messages = ['Hello', 'Hi', 'Hey'];
    const receptors = ['RECIPIENT_1', 'RECIPIENT_2', 'RECIPIENT_3'];
    const senders = ['SENDER_1', 'SENDER_2', 'SENDER_3'];
    const result = await kavenegar.sendArray({ message: messages, receptor: receptors, sender: senders });
    console.log('Multiple SMS sent:', result);
}

Verify a Phone Number with a Token

async function verifyPhoneNumber() {
    const receptor = 'RECIPIENT_NUMBER';
    const token = '123456';
    const template = 'TEMPLATE_NAME';
    const result = await kavenegar.verifyLookup({ receptor, token, template });
    console.log('Verification result:', result);
}

Check SMS Status

async function checkSMSStatus() {
    const messageIds = [1234567890, 9876543210]; // Replace with actual message IDs
    const status = await kavenegar.status({ messageid: messageIds });
    console.log('SMS Status:', status);
}

Cancel SMS Sending

async function cancelSMSSending() {
    const messageId = 1234567890; // Replace with actual message ID
    const result = await kavenegar.cancel({ messageid: messageId });
    console.log('SMS Cancelled:', result);
}

Receive SMS

async function receiveSMS() {
    const lineNumber = 'YOUR_LINE_NUMBER'; // Replace with actual line number
    const isRead = 0; // 0 for unread, 1 for read
    const receivedMessages = await kavenegar.receive({ lineNumber, isRead });
    console.log('Received SMS:', receivedMessages);
}

Retrieve Account Information

async function getAccountInfo() {
    const accountInfo = await kavenegar.accountInfo();
    console.log('Account Information:', accountInfo);
}

Configure Account Settings

async function configureAccount() {
    const accountConfigs = {
        apilogs: 'enabled',
        dailyreport: 'disabled',
        debugmode: 'enabled',
        defaultsender: 'YOUR_SENDER_ID',
        mincreditalarm: 100,
        resendfailed: 'enabled'
    };
    const configuredSettings = await kavenegar.accountConfig(accountConfigs);
    console.log('Account Settings Configured:', configuredSettings);
}

Make Text-to-Speech Call

async function makeTTS() {
    const receptor = 'RECIPIENT_NUMBER';
    const message = 'Hello, this is a text-to-speech message.';
    const result = await kavenegar.callMakeTTS({ receptor, message });
    console.log('Text-to-Speech Call result:', result);
}

Other functions you can use

  • statusLocalMessageId
  • select
  • selectOutbox
  • latestOutbox
  • countInbox
  • countOutbox

Feel free to customize and expand these examples according to your needs!

This README provides clear instructions on how to use the Kavenegar API module and includes examples for some of its functions.

For more information, visit the Kavenegar official website.

Keywords

FAQs

Package last updated on 07 Apr 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc