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

@netgsm/sms

v1.1.10

Published

Netgsm API Client for SMS sending and reporting

Readme

@netgsm/sms

npm version License: MIT Node.js CI TypeScript PRs Welcome Downloads

Official Node.js client for the Netgsm SMS API. This package enables you to easily use Netgsm SMS services in your Node.js applications.

Table of Contents

Features

  • SMS sending (instant and scheduled)
  • Bulk SMS sending (different messages for each recipient)
  • SMS report querying
  • Message header listing
  • Balance querying
  • Inbox message listing
  • Canceling scheduled SMS
  • TypeScript support
  • Comprehensive error handling

Requirements

  • Node.js 14.0.0 or higher
  • Netgsm account and API access

Installation

Using NPM:

npm install @netgsm/sms

Using Yarn:

yarn add @netgsm/sms

Quick Start

CommonJS usage

// Option 1: Named imports
const { Netgsm, SmsStatus, BalanceType } = require('@netgsm/sms');

// Option 2: Default import
const Netgsm = require('@netgsm/sms').default;
// or
const { default: Netgsm } = require('@netgsm/sms');

// Configure Netgsm client
const netgsm = new Netgsm({
  username: 'YOUR_USERNAME',
  password: 'YOUR_PASSWORD',
  appname: 'YOUR_APP_NAME' // Optional
});

// Send SMS
async function sendSms() {
  try {
    const response = await netgsm.sendRestSms({
      msgheader: 'YOUR_HEADER', // SMS header
      encoding: 'TR', // Turkish character support
      startdate: '010620241530',       // Optional (format: ddMMyyyyHHmm)
      stopdate: '010620241630',        // Optional (format: ddMMyyyyHHmm)
      messages: [
        { msg: 'Message content', no: '5XXXXXXXXX' },
        { msg: 'Message content', no: '5YYYYYYYYY' }
      ]
    });
    
    console.log('SMS sent:', response);
    return response.jobid;
  } catch (error) {
    console.error('Error:', error);
  }
}

// Call the function
sendSms();

ES Modules / TypeScript usage

// Option 1: Default import (recommended)
import Netgsm from '@netgsm/sms';

// Option 2: Named imports
import { Netgsm, SmsStatus, BalanceType } from '@netgsm/sms';

// Configure Netgsm client
const netgsm = new Netgsm({
  username: 'YOUR_USERNAME',
  password: 'YOUR_PASSWORD',
  appname: 'YOUR_APP_NAME' // Optional
});

// Type-safe usage
async function checkBalance() {
  try {
    const balance = await netgsm.getBalance({
      type: BalanceType.CREDIT
    });
    
    console.log('Balance:', balance);
    return balance;
  } catch (error) {
    console.error('Error:', error);
  }
}

Usage Examples

For more examples, check the examples directory:

API Reference

Configuration

const netgsm = new Netgsm({
  username: 'YOUR_USERNAME', // Required
  password: 'YOUR_PASSWORD',  // Required
  appname: 'YOUR_APP_NAME'    // Optional
});

Sending SMS

const response = await netgsm.sendRestSms({
  msgheader: 'YOUR_HEADER',
  encoding: 'TR',              // TR, ASCII
  startdate: '010620241530',   // Optional (format: ddMMyyyyHHmm)
  stopdate: '010620241630',    // Optional (format: ddMMyyyyHHmm)
  messages: [
    { msg: 'Message content', no: '5XXXXXXXXX' },
    { msg: 'Message content', no: '5YYYYYYYYY' }
  ]
});

Querying SMS Report

const report = await netgsm.getReport({
  bulkIds: ['12345678'] // Job ID received after sending  
});

Checking Balance

const balance = await netgsm.getBalance({
  type: BalanceType.CREDIT // 1: Package/campaign info, 2: Credit info
});

Listing Headers

const headers = await netgsm.getHeaders();

Listing Inbox Messages

const inbox = await netgsm.getInbox({
  startdate: '01012024', // Start date (format: ddMMyyyy)
  stopdate: '31012024'   // End date (format: ddMMyyyy)
});

Canceling Scheduled SMS

const cancelResult = await netgsm.cancelSms({
  jobid: '12345678' // Job ID of the delivery to cancel
});

For more detailed API reference, visit the API Documentation page.

Development

To set up the development environment:

# Clone the repository
git clone https://github.com/netgsm/netgsm-sms-js.git
cd netgsm-sms-js

# Install dependencies
npm install

# Run tests
npm test

# Build the library
npm run build

Contributing

If you want to contribute to this project, please review the CONTRIBUTING.md file. All contributions are evaluated under the Contributors Agreement.

License

This project is licensed under the MIT license. See the LICENSE file for details.

Security

For security vulnerabilities or concerns, please review the SECURITY.md file and follow the specified steps.

Contact

For technical support or questions about the SDK, please contact us at:

We're here to help you integrate Netgsm SMS services into your applications successfully.