Skip to content

nextsms/node-nextsms

Repository files navigation

NextSMS Client for Node.js

Tests


The NextSMS SDK allows developers to easily integrate NextSMS solutions in their Javascript code, and build robust applications and software.

Documentation

Take a look at the SDK docs here.

Usage

NOTE:
> Test Mode ONLY Single destination and Multiple destinations APIs support testing mode.

Quick Examples

yarn add @nextsms/js-client
# or
npm i @nextsms/js-client
import NextSMS from '@nextsms/js-client';

// Populate the credentials
const username = 'username';
const password = 'password';
const apiKey = null';

// Initiate with credentials
let nextsms = new NextSMS({ username, password, apiKey, environment: 'testing' });

const data = {
  from: 'NEXTSMS',
  to: '255123456789',
  text: 'Hello World',
};

// Send the sms
nextsms
  .singleDestination(data)
  .then(data => {
    // Print results
    console.log(data);
  })
  .catch(error => {
    console.log('error: ' + error);
  });

Using base64 api key

import NextSMS from '@nextsms/js-client';

// Populate the credentials
const username = null;
const password = null;
const apiKey = 'yourBase64Key'; // this is generated on https://www.blitter.se/utils/basic-authentication-header-generator/ as mentioned on nextsms api documentation.

// Initiate with credentials
let nextsms = new NextSMS({ username, password, apiKey, environment: 'testing' });

const data = {
  from: 'NEXTSMS',
  to: '255123456789',
  text: 'Hello World',
};

// Send the sms
nextsms
  .singleDestination(data)
  .then(data => {
    // Print results
    console.log(data);
  })
  .catch(error => {
    console.log('error: ' + error);
  });

Testing

yarn test

Opening Issues

If you have a feature request or you encounter a bug, please file an issue on our issue tracker on GitHub.

Credits

License

The MIT License (MIT). Please see License File for more information.