npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

notify-lk

v1.0.1

Published

A Node.js package for interacting with the Notify.lk API. This package provides functionality to send SMS messages, check account status, manage contacts, and retrieve SMS history using the Notify.lk service.

Downloads

3

Readme

Notify.LK Documentation

Introduction

Welcome to the NotifyLK NPM package documentation. This package enables you to send SMS messages, check account status, and manage contacts using the Notify.lk API.

Installation

npm install notify-lk --save

Run the above command in your project directory to install the package.

Usage

Here’s how to use the NotifyLK package in your Node.js application:

const NotifyLK = require('notify-lk');
    
const notify = new NotifyLK('YOUR_USER_ID', 'YOUR_API_KEY', 'YOUR_SENDER_ID');
    
notify.sendSMS('9471XXXXXXX', 'Hello from NotifyLK')
        .then(response => console.log(response))
        .catch(error => console.error(error));

API Reference

NotifyLK(userId, apiKey, senderId)

Constructor for creating a new instance of the NotifyLK class.

  • userId: string - Your Notify.lk user ID.
  • apiKey: string - Your Notify.lk API key.
  • senderId: string - The sender ID for your messages (default: NotifyDEMO).

sendSMS(to, message, options)

Sends an SMS to the specified number.

  • to: string - The recipient's phone number in 94XXXXXXXXX format.
  • message: string - The message to be sent.
  • options: object - Additional options for the message (optional).

getAccountStatus()

Retrieves the account status including the balance and active status.

Examples

1. Sending a Simple SMS

This example demonstrates how to send a simple SMS using the NotifyLK package:

const NotifyLK = require('notify-lk');
    
const notify = new NotifyLK('YOUR_USER_ID', 'YOUR_API_KEY', 'YOUR_SENDER_ID');
    
notify.sendSMS('9471XXXXXXX', 'Hello from NotifyLK')
    .then(response => console.log('SMS Sent:', response))
    .catch(error => console.error('Error Sending SMS:', error));

2. Checking Account Status

This example shows how to check your account's status, including balance and active status:

notify.getAccountStatus()
    .then(status => console.log('Account Status:', status))
    .catch(error => console.error('Error Fetching Account Status:', error));

3. Sending SMS with Unicode Characters

To send an SMS containing Unicode characters (e.g., emojis, non-Latin scripts), include the type option:

notify.sendSMS('9471XXXXXXX', 'Hello from NotifyLK 😊', { type: 'unicode' })
    .then(response => console.log('Unicode SMS Sent:', response))
    .catch(error => console.error('Error Sending Unicode SMS:', error));

4. Bulk SMS Sending

Sending SMS to multiple recipients in a loop:

const numbers = ['9471XXXXXXX', '9472XXXXXXX', '9473XXXXXXX'];
const message = 'Hello from NotifyLK';
    
numbers.forEach(number => {
    notify.sendSMS(number, message)
        .then(response => console.log(`SMS Sent to ${number}:`, response))
        .catch(error => console.error(`Error Sending SMS to ${number}:`, error));
    });

5. Handling SMS Errors Gracefully

This example demonstrates how to handle errors, such as invalid phone numbers or API issues:

notify.sendSMS('invalid_number', 'This message will fail')
    .then(response => console.log('SMS Sent:', response))
    .catch(error => {
        if (error.response && error.response.data) {
            console.error('API Error:', error.response.data);
        } else {
            console.error('Unknown Error:', error.message);
        }
    });

6. Scheduling SMS for Future Delivery

If Notify.lk supports scheduling (hypothetical, as the real API may not), you could do something like this:

const scheduleDate = new Date(Date.now() + 60 * 60 * 1000); // 1 hour from now
notify.sendSMS('9471XXXXXXX', 'This message is scheduled for future delivery', { send_at: scheduleDate.toISOString() })
    .then(response => console.log('Scheduled SMS Sent:', response))
    .catch(error => console.error('Error Scheduling SMS:', error));

Author

This package is maintained by Omindu Dissanayake.

For more information, visit the GitHub profile. License

This package is licensed under the MIT License. See the LICENSE file for more information.