SMSGlobal node SDK

The SMSGlobal Node library provides convenient access to the SMSGlobal REST API from node applications.
Example
Check out the code examples
SMSGlobal rest API credentials
Rest API credentials can be provided in the SMSGlobal client or node environment variables. The credential variables are SMSGLOBAL_API_KEY
and SMSGLOBAL_API_SECRET
Installation
npm install --save https://github.com/smsglobal/smsglobal-node
Usage
- Require
smsglobal
in your file
const apiKey = 'YOUR_API_KEY';
const apiSecret = 'YOUR_API_SECRET';
var smsglobal = require('smsglobal')(apiKey, secret);
To send a sms
var payload = {
origin: 'from number',
destination: 'destination',
message: 'This is a test message'
}
smsglobal.sms.send(payload, function (error, response) {
console.log(response);
});
To fetch a list outgoing sms
var promise = smsglobal.sms.getAll();
promise
.then(function(response) {
console.log(response)
})
.catch(function(error){
console.log(error)
});
To fetch an outgoing sms by id
var id = 'outgoing-sms-id';
var promise = smsglobal.sms.get(id);
promise
.then(function(response) {
console.log(response)
})
.catch(function(error){
console.log(error)
});
To fetch a list incoming sms
var promise = smsglobal.sms.incoming.getAll();
promise
.then(function(response) {
console.log(response)
})
.catch(function(error){
console.log(error)
});
To fetch an incoming sms by id
var id = 'incoming-sms-id';
var promise = smsglobal.sms.incoming.get(id);
promise
.then(function(response) {
console.log(response)
})
.catch(function(error){
console.log(error)
});
All method returns promise if no callback is given
Running tests
Run the tests:
npm test
To run test with code coverage report
npm run mocha-only
Following endpoints are covered
Reference
REST API Documentation