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

termii-js

v0.0.1

Published

A simple JS SDK for made for Termii API

Downloads

25

Readme

Termii API Client

GitHub Workflow Status GitHub Repo stars Twitter Follow

A NodeJS wrapper made for Termii API

Termii API Documentation

For complete API documentation, up-to-date parameters, responses and errors, please refer to https://developer.termii.com.

Installation

This is a Node.js module available through the npm registry. Installation is done using the npm install command

$ npm install termii-js

Usage

Simple usage examples

  • Send SMS
const Termii = require('termii');

const termii = new Termii('api_key', 'sender_id');

// Send simple SMS
const sms = await termii.sendSMS('2347063516197', 'Hello this is a message');

// Set SMS options
const options = { channel: 'generic' };
const sms = await termii.sendSMS(
    '2347065548126',
    'Hello this is a message',
    options
);

// Optionally you can set SMS option first before calling the sendSMS method
termii.setSMSOptions(options);
const sms = await termii.sendSMS('2347065940103', 'Hello this is a message');

// You can as well send to many numbers by passing array of numbers as strings
const recipients = ['2347065026902', '2347087675643'];
const sms = await termii.sendSMS(recipients, 'Hello this is a message');

// Pormise join

You can chain then() and catch() method like below

termii.sendSMS(recipients, 'this is a test message')
    .then((response) => {
        if (response.code === 'ok') {
            // Do something interesting
        }
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });

in async/await

app.get('/api/sendsms', async (req, res, next) => {
    try {
        const sms = await termii.sendSMS(recipients, 'this is a test message');
        if (sms.code === 'ok') {
            // Do something interesting here
        }

        res.json(sms);
    } catch (err) {
        console.log(err);
        next(err);
    }
});

You can send SMS with Termii auto-generated phone number as well. The sendSMSWithAutomatedNumber() method accept only two arguments. First arguments 'recipients' [string || Array] and 'message' [string].

const Termii = require('termii');

const termii = new Termii('api_key', 'sender_id');

termii.sendSMSWithAutomatedNumber(recipients, 'this is a test message')
    .then((response) => {
        if (response.code === 'ok') {
            // Do something interesting
        }
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });

Configuration

You can specify the API key and the sender ID in the environment variable 'TERMII_API_KEY' and 'TERMII_SENDER_ID' then create a new instance without passing the constructor arguments.

NOTE: If you don't specify sender ID in the environment variable 'TERMII_SENDER_ID' you will have to pass it to the constructor as second argument else "Termii" will be used as a default sender ID. API key is made mandatory, you specify it in the environment variable 'TERMII_API_KEY' or pass to the constructor

const Termii = require('termii');

// Create instance without constructor arguments
// NOTE: You need specify this arguments in environment
// variable 'TERMII_API_KEY' and 'TERMII_SENDER_ID'
const termii = new Termii();

Comming soon

Send token and verify token

License

MIT License