https://github.com/moceanapi/mocean-sdk-nodejs
✉📲 SDK Library for NodeJS to send SMS for FREE using MoceanAPI sms solution.
https://github.com/moceanapi/mocean-sdk-nodejs
moceanapi nodejs sms sms-api sms-client sms-messages
Last synced: 5 months ago
JSON representation
✉📲 SDK Library for NodeJS to send SMS for FREE using MoceanAPI sms solution.
- Host: GitHub
- URL: https://github.com/moceanapi/mocean-sdk-nodejs
- Owner: MoceanAPI
- License: mit
- Created: 2018-06-27T03:52:08.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-03-24T10:16:04.000Z (almost 3 years ago)
- Last Synced: 2025-07-30T14:52:10.398Z (6 months ago)
- Topics: moceanapi, nodejs, sms, sms-api, sms-client, sms-messages
- Language: JavaScript
- Homepage: https://moceanapi.com/
- Size: 163 KB
- Stars: 1
- Watchers: 0
- Forks: 4
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
MoceanAPI Client Library for NodeJS
============================
[](https://www.npmjs.com/package/mocean-sdk)
[](https://travis-ci.com/MoceanAPI/mocean-sdk-nodejs)
[](https://app.codacy.com/project/MoceanAPI/mocean-sdk-nodejs/dashboard)
[](https://www.npmjs.com/package/mocean-sdk)
[](https://www.npmjs.com/package/mocean-sdk)
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][signup].
* [Installation](#installation)
* [Usage](#usage)
* [Example](#example)
## Installation
To use the client library you'll need to have [created a Mocean account][signup].
To install the NodeJS client library using Node Package Manager (NPM).
```bash
npm install mocean-sdk
```
## Usage
Create a client with your API key and secret:
```javascript
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][doc_sms] 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][doc_sms].
```javascript
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
```javascript
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][doc_main] for more usage
License
-------
This library is released under the [MIT License][license]
[signup]: https://dashboard.moceanapi.com/register?medium=github&campaign=nodejs-sdk
[doc_main]: https://moceanapi.com/docs/?javascript
[doc_sms]: https://moceanapi.com/docs/?javascript#send-sms
[license]: LICENSE.txt