Skip to content

A nodejs wrapper for nexmo API to send SMS and TTS

License

Notifications You must be signed in to change notification settings

t-d-d/simple-nexmo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A nodejs wrapper for nexmo API to send SMS NPM version

NPM status

Installation

The preferred way to install is use the npm package manager for Node.js.

$ npm install simple-nexmo

Initialize

After you've installed, you can require the package in your node application using require:

var Nexmo = require('simple-nexmo');
var nexmo = new Nexmo();

API_KEYAPI_SECRET: Required. You will find them in "API Settings" in Nexmo Dashboard

API_PROTOCOL: Optional. http or https

DEBUG_MODE : Optional. Set to true to see debug informations

nexmo.init(API_KEY, API_SECRET, API_PROTOCOL, DEBUG_MODE);

Supported API

Messaging SMS API

Developer API

Unsupported API

The following API will supported in the future.

Developer API

  • nexmo.updateNumberCallback(countryCode, msisdn, newUrl, sysType, callback)

Messaging SMS - Send a Plain text message

from: Required. Sender address may be alphanumeric. Ex: MyCompany20

to: Required. Mobile number in international format, and one recipient per request. Ex: 886912345678

message: Required. Text message. Ex: Hello World!

nexmo.sendTextMessage(from, to, message, callback)

Messaging SMS - Send a Binary data message

from: Required. Sender address may be alphanumeric. Ex: MyCompany20

to: Required. Mobile number in international format, and one recipient per request. Ex: 886912345678

body: Required. Hex encoded binary data. Ex: 0011223344556677

udh: Required. Hex encoded udh. Ex: 06050415811581

nexmo.sendBinaryMessage(from, to, body, udh, callback)

Messaging SMS - Send a WAP push message

from: Required. Sender address may be alphanumeric. Ex: MyCompany20

to: Required. Mobile number in international format, and one recipient per request. Ex: 886912345678

title: Required. Title of WAP Push. Ex: MySite

url: Required. WAP Push URL. Ex: http://www.mysite.com

validity: Optional. Set how long WAP Push is available in milliseconds. Ex: 86400000 (Default: 48 hours.)

nexmo.sendWapPushMessage(from, to, title, url, validity, callback)

Account: Get Balance - Retrieve current account balance

nexmo.getBalance(callback)

Account: Pricing - Retrieve our outbound pricing for a given country

countryCode: Required. A 2 letter country code. Ex: CA

nexmo.getPricing(countryCode ,callback)

Account: Settings - Update API secret

newSecret: Required. New API secret (8 characters max)

nexmo.updateSecret(newSecret, callback)

Account: Settings - Update inbound call back URL

newUrl: Required. Inbound call back URL. Ex: http://mycallback.servername

nexmo.updateMoCallBackUrl(newUrl, callback)

Account: Settings - Update DLR call back URL

newUrl: Required. DLR call back URL. Ex: http://mycallback.servername

nexmo.updateDrCallBackUrl(newUrl, callback)

Account: Top Up - Top-up your account, only if you have turn-on the 'auto-reload' feature. The top-up amount is the one associated with your 'auto-reload' transaction.

transactionId: Required. The transaction id associated with your first 'auto reload' top-up. Ex: 00X123456Y7890123Z

nexmo.getTopUp(transactionId, callback)

Account: Numbers - Get all inbound numbers associated with Nexmo account

nexmo.getNumbers(callback)

Number: Search - Get available inbound numbers for a given country

countryCode: Required. Country code. Ex: CA

pattern: Optional. A matching pattern. Ex: 888

index: Optional. Page index (>0, default 1). Ex: 2

size: Optional. Page size (max 100, default 10). Ex: 25

nexmo.searchNumbers(countryCode, pattern, index, size, callback)

Number: Buy - Purchase a given inbound number

countryCode: Required. Country code. Ex: ES

msisdn: Required. An available inbound number Ex: 34911067000

nexmo.buyNumber(countryCode, msisdn, callback)

Number: Cancel - Cancel a given inbound number subscription

countryCode: Required. Country code. Ex: ES

msisdn: Required. One of your inbound numbers Ex: 34911067000

nexmo.cancelNumber(countryCode, msisdn, callback)

Search: Message - Search a previously sent message for a given message id

messageId: Required. Your message id received at submission time Ex: 00A0B0C0

nexmo.searchMessage(messageId, callback)

Search: Messages - Search sent messages by message ids

messageIds: Required. A list of message ids, up to 10 Ex: [00A0B0C0', '00A0B0C1', '00A0B0C2' ]

nexmo.searchMessageByIds(messageIds, callback)

Search: Messages - Search sent messages by recipient and date

date: Required. Message date submission YYYY-MM-DD Ex: 2013-11-03

to: Required. A recipient number Ex: 886912345678

nexmo.searchMessagesByRecipient(date, to, callback)

Search: Rejections - Search rejected messages

date: Required. Message date submission YYYY-MM-DD Ex: 2013-11-03

to: Optional. A recipient number Ex: 886912345678

nexmo.searchRejections(date, to, callback)

Callback

Callback from all API calls returns 2 parameters: error and a json object.

An example callback function:

function callback (err, response) {
    if (err) {
        console.log(err);
    } else {
        console.dir(response);
    }
}

Refer offical docuemnts to get the schema for the returned message response object.

The MIT License (MIT)

Copyright © 2013-2014 Calvert Yang

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

githalytics.com alpha

About

A nodejs wrapper for nexmo API to send SMS and TTS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%