mocean-sdk v2.2.2
MoceanAPI Client Library for NodeJS
This is the NodeJS client library for use Mocean's API. To use this, you'll need a Mocean account. Sign up for free at moceanapi.com.
Installation
To use the client library you'll need to have created a Mocean account.
To install the NodeJS client library using Node Package Manager (NPM).
npm install mocean-sdkUsage
Create a client with your API key and secret:
const client = require('mocean-sdk');
var token = new client.Client('API_KEY_HERE','API_SECRET_HERE');
var mocean = new client.Mocean(token);Example
To use Mocean's SMS API to send an SMS message, call the mocean.sms.send() method.
The API can be called directly, using a simple array of parameters, the keys match the parameters of the API.
mocean.sms()
.send({
'mocean-from': 'MOCEAN',
'mocean-to': '60123456789',
'mocean-text': 'Hello World'
}, function(err, res) {
if (err) throw err;
console.log(res);
});Extras
This library support both callbacks and promises
To use callbacks, simple pass the callback function in second parameter like example above
For promises, refer to the example below
const promise = mocean.sms()
.send({
'mocean-from': 'MOCEAN',
'mocean-to': '60123456789',
'mocean-text': 'Hello World'
});
promise.then(res => {
console.log(res);
});
promise.catch(err => {
throw err;
});Documentation
Kindly visit MoceanApi Docs for more usage
License
This library is released under the MIT License