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 🙏

© 2025 – Pkg Stats / Ryan Hefner

termii-nest-sdk

v1.0.2

Published

An SDK that enables NestJS developers to integrate Termii's messaging features seamlessly without directly interacting with the API.

Readme

Termii NestJS SDK Documentation

Introduction

The termii-nest-sdk is a NestJS-based software development kit (SDK) designed to simplify the integration of Termii APIs into NestJS projects. It provides a structured and efficient way to interact with Termii's messaging and authentication services.

Installation

To install the SDK, run the following command:

npm install termii-nest-sdk

or with Yarn:

yarn add termii-nest-sdk

Configuration

To set up the SDK, import the module into your AppModule and pass the required configuration options.

Example Configuration

import { Module } from '@nestjs/common';
import { TermiiSDKModule } from 'termii-nest-sdk';

@Module({
  imports: [
    TermiiSDKModule.register({
      apiKey: process.env.API_KEY, // Ensure API_KEY is set in your environment variables
      baseUrl: 'https://v3.api.termii.com',
      isGlobal: true // Optional flag (default: false). If false, you must import it into each module that needs it.
    }),
  ],
})
export class AppModule {}

Environment Variables

Ensure the following environment variables are set:

API_KEY=[your_api_key]
BASE_URL=https://v3.api.termii.com

Authentication

Some Termii API requests require authentication. The SDK manages authentication using an API key, which must be provided during module registration.

Usage

Once configured, the SDK can be utilized in any service or controller.

Example: Sending an SMS Message

import { Injectable } from '@nestjs/common';
import { AbstractMessagingService } from 'termii-nest-sdk';

@Injectable()
export class NotificationService {
  constructor(private readonly messagingService: AbstractMessagingService) {}
  
  async sendSMSMessage() {
    const samplePayload = {
      to: '[recipient]', // Recipient's phone number
      from: '[sender_id]', // Approved sender ID
      sms: 'Hi there, testing Termii',
      type: '[message_type]', // Message type (e.g., plain)
      channel: '[channel_type]', // Channel type (e.g., dnd, whatsapp, generic)
    };
    
    return this.messagingService.sendSingleMessage(samplePayload);
  }
}

Available APIs in the SDK

AbstractMessagingService

Handles sending text messages across different messaging channels.

AbstractNumberService

Manages sending messages using Termii's auto-generated messaging numbers.

AbstractSenderIDService

Retrieves registered business statuses and requests sender ID registration.

AbstractTokenService

Facilitates OTP (One-Time Password) sending and verification.

API Methods

Messaging Services

  • sendSingleMessage(payload: TmSingleMessageRequestPayload): Sends a message to a single recipient.
  • sendBulkMessage(payload: TmBulkMessageRequestPayload): Sends messages to multiple recipients.

Number Services

  • sendMessage(payload: TmNumberPayload): Sends messages using Termii's generated numbers.

Sender ID Services

  • fetchSenderId(): Retrieves details of registered sender IDs.
  • requestSenderId(payload: TmRequestSenderIDPayload): Requests a sender ID.

Token Services

  • sendToken(payload: TmSendTokenPayload): Sends OTPs across multiple channels.
  • verifyToken(payload: TmVerifyTokenPayload): Verifies sent tokens.

Error Handling

All SDK methods return structured responses. Errors can be managed using try-catch blocks.

try {
  const response = await messagingService.sendSingleMessage(payload);
  console.log(response);
} catch (error) {
  console.error('Error:', error.message);
}

Best Practices

  • Always handle API errors gracefully.
  • Use environment variables to manage sensitive credentials securely.
  • Enable logging for better debugging.

Logging & Debugging

Enable verbose logging by setting the following environment variable:

DEBUG=sdk:* npm start

License

This SDK is licensed under the MIT License. See the LICENSE file for details.

Contributing

We welcome contributions! Follow these steps to contribute:

  1. Fork the repository.
  2. Create a new branch for your feature.
  3. Commit and push your changes.
  4. Open a pull request.

Support

For issues or questions, please open an issue on the GitHub repository or contact via email: [email protected].

Authors