node package manager


Nexmo REST API client for Node.js. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.

Nexmo Client Library for Node.js

A Node.JS REST API Wrapper library for Nexmo (

For full API documentation refer to

npm install nexmo
var Nexmo = require('nexmo');
var nexmo = new Nexmo({apiKey: API_KEY, apiSecret: API_SECRET}, {debug: DEBUG});
  • API_KEY - API Key from Nexmo
  • API_SECRET - API SECRET from Nexmo
  • DEBUG - set this to true to debug library calls
nexmo.message.sendSms(sender, recipient, message, opts, callback);
  • opts - parameter is optional
nexmo.message.sendBinaryMessage(fromnumber, tonumber,body, udh, callback);
  • body - Hex encoded binary data
  • udh - Hex encoded udh
nexmo.message.sendWapPushMessage(fromnumber, tonumber, title, url, validity, callback);
  • validity - is optional (if given should be in milliseconds)
nexmo.message.shortcodeAlert(recipient, messageParams, opts, callback);
nexmo.number.getPricing(countryCode, callback);
  • countryCode - 2 letter ISO Country Code
nexmo.number.getPhonePricing(product, countryCode, callback);
  • product - either voice or sms
  • countryCode - 2 letter ISO Country Code
nexmo.number.get(options, callback);
  • options parameter is an optional Dictionary Object containing any of the following parameters
    • pattern
    • search_pattern
    • index
    • size

For more details on what the above options mean refer to the Nexmo API documentation



options parameter is optional. They can be one of the following :

  1. number pattern to match the search (eg. 1408)
  2. Dictionary Object optionally containing the following parameters :
    • pattern
    • search_pattern
    • features
    • index
    • size

For more details on what the above options mean refer to the Nexmo API documentation

Example:'US',{pattern:3049,index:1,size:50,features:'VOICE',search_pattern:2},consolelog);, msisdn, callback);
nexmo.number.cancel(countryCode, msisdn, callback);
nexmo.number.update(countryCode, msisdn, params, callback);

params is a dictionary of parameters per documentation

nexmo.voice.sendTTSMessage = function(<TO_NUMBER>,message,options,callback);
nexmo.sendTTSPromptWithCapture(<TO_NUMBER>,message,<MAX_DIGITS>, <BYE_TEXT>,options,callback);
nexmo.voice.sendTTSPromptWithConfirm(<TO_NUMBER>, message ,<MAX_DIGITS>,'<PIN_CODE>',<BYE_TEXT>,<FAILED_TEXT>,options,callback);<TO_NUMBER>,<ANSWER_URL>,options,callback);

For more information check the documentation at


For more information check the documentation at


For more information check the documentation at<ONE_REQUEST_ID or ARRAY_OF_REQUEST_ID>,callback);

For more information check the documentation at


For more information check the documentation at

nexmo.numberInsight.get({level: 'basic', number: NUMBER}, callback);

For more information check the documentation at


nexmo.numberInsight.get({level: 'basic', number: '1-234-567-8900'}, consolelog);
nexmo.numberInsight.get({level: 'standard', number: NUMBER}, callback);

For more information check the documentation at


nexmo.numberInsight.get({level: 'standard', number: '1-234-567-8900'}, consolelog);
nexmo.numberInsight.get({level: 'advanced', number: NUMBER}, callback);

For more information check the documentation at

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

An example callback function:

function consolelog (err,messageResponse) {
    if (err) {
    } else {

Refer here to get the schema for the returned message response object.

Run the

npm test

For testing purposes you can also use setHost function to make the library send requests to another place like localhost instead of real Nexmo. Feel free to catch and process those requests the way you need. A usage example:


Note that default port is 443 and nexmo does https calls in such a case. You can use setPort function to make it proper for your testing environment. When port is not 443 it will make requests via http protocol. Have a look at an example:


There are some basic examples which will test the functionality. They uses environment variables for settings for the tests. The environment variables are:

  • API_KEY = The API key provided by Nexmo for your account
  • API_SECRET = The secret provided by NExmo for your account
  • FROM_NUMBER = The phone number to send messages and make calls from.
  • TO_NUMBER = The phone number to send messages and make calls to.
  • MAX_DIGITS = The maximum number of digits for the pin code.
  • ANSWER_URL = The URL which has the VoiceXML file to control the call functionality
  • PIN_CODE = The digits you must enter to confirm the message

The simplest way to run the examples is to create a .env file in the examples directory with the following:


Then run:

node examples/pre-v1.js


node examples/v1-beta.js