
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Nexmo REST API client for Node.js. API support for SMS, Voice Calls, Text-to-Speech, Numbers, Verify (2FA) and more.
A Node.JS REST API Wrapper library for Nexmo (http://nexmo.com/)
For full API documentation refer to https://docs.nexmo.com/
Installation | Constructor | Messaging | Voice | Verify | Number Insight | Applications Management
npm install nexmo
var Nexmo = require('nexmo');
var nexmo = new Nexmo({
apiKey: API_KEY,
apiSecret: API_SECRET,
applicationId: APP_ID,
privateKey: PRIVATE_KEY_PATH,
}, options });
apiKey
- API Key from NexmoapiSecret
- API SECRET from NexmoapplicationId
- The Nexmo Application ID to be used when creating JWTs. Required for voice related functionality.privateKey
- The path to the Private Key to be used when creating JWTs. Required for voice related functionality.options
- Additional options for the constructorOptions are:
{
// If true, log information to the console
debug: true|false,
// append info the the User-Agent sent to Nexmo
// e.g. pass 'my-app' for /nexmo-node/1.0.0/4.2.7/my-app
appendToUserAgent: string,
// Set a custom logger
logger: {
log: function() {level, args...}
info: function() {args...},
warn: function() {args...}
}
}
nexmo.message.sendSms(sender, recipient, message, options, callback);
opts
- parameter is optional. See SMS API Referencenexmo.message.sendBinaryMessage(fromnumber, tonumber, body, udh, callback);
body
- Hex encoded binary dataudh
- Hex encoded udhnexmo.message.sendWapPushMessage(fromnumber, tonumber, title, url, validity, callback);
validity
- is optional (if given should be in milliseconds)nexmo.message.shortcodeAlert(recipient, messageParams, opts, callback);
For detailed information please see the documentation at https://docs.nexmo.com/voice/call
Requires applicationId
and privateKey
to be set on the constructor.
nexmo.calls.create({
to: [{
type: 'phone',
number: TO_NUMBER
}],
from: {
type: 'phone',
number: FROM_NUMBER
},
answer_url: [ANSWER_URL]
}, callback);
For more information see https://docs.nexmo.com/voice/voice-api/api-reference#call_create
nexmo.calls.get(callId, callback);
For more information see https://docs.nexmo.com/voice/voice-api/api-reference#call_create
nexmo.calls.get({status: 'completed'}, callback);
The first parameter can contain many properties to filter the returned call or to page results. For more information see the Calls API Reference.
nexmo.calls.stream.start(
callId,
{
stream_url: [
'https://nexmo-community.github.io/ncco-examples/assets/voice_api_audio_streaming.mp3'
],
loop: 1
});
For more information see https://docs.nexmo.com/voice/voice-api/api-reference#stream_put
nexmo.calls.stream.stop(callId);
For more information see https://docs.nexmo.com/voice/voice-api/api-reference#stream_delete
nexmo.calls.dtmf.send(callId, params, callback);
For more information see https://docs.nexmo.com/voice/voice-api/api-reference#dtmf_put
nexmo.verify.request({number:<NUMBER_TO_BE_VERIFIED>,brand:<NAME_OF_THE_APP>},callback);
For more information check the documentation at https://docs.nexmo.com/verify/api-reference/api-reference#vrequest
nexmo.verify.check({request_id:<UNIQUE_ID_FROM_VERIFICATION_REQUEST>,code:<CODE_TO_CHECK>},callback);
For more information check the documentation at https://docs.nexmo.com/verify/api-reference/api-reference#check
nexmo.verify.search(<ONE_REQUEST_ID or ARRAY_OF_REQUEST_ID>,callback);
For more information check the documentation at https://docs.nexmo.com/verify/api-reference/api-reference#search
nexmo.verify.control({request_id:<UNIQUE_ID_FROM_VERIFICATION_REQUEST>,cmd:<CODE_TO_CHECK>},callback);
For more information check the documentation at https://docs.nexmo.com/verify/api-reference/api-reference#control
nexmo.numberInsight.get({level: 'basic', number: NUMBER}, callback);
For more information check the documentation at https://docs.nexmo.com/number-insight/basic
Example:
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 https://docs.nexmo.com/number-insight/standard
Example:
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 https://docs.nexmo.com/number-insight/advanced
For an overview of applications see https://docs.nexmo.com/tools/application-api
nexmo.applications.create(name, type, answerUrl, eventUrl, options, callback);
For more information see https://docs.nexmo.com/tools/application-api/api-reference#create
nexmo.applications.get(appId, callback);
For more information see https://docs.nexmo.com/tools/application-api/api-reference#retrieve
nexmo.application.get(options, callback);
For more information see https://docs.nexmo.com/tools/application-api/api-reference#list
nexmo.applications.update(appId, name, type, answerUrl, eventUrl, options, callback);
For more information see https://docs.nexmo.com/tools/application-api/api-reference#update
nexmo.application.delete(appId, callback);
For more information see https://docs.nexmo.com/tools/application-api/api-reference#delete
nexmo.account.checkBalance(callback);
nexmo.number.getPricing(countryCode, callback);
countryCode
- 2 letter ISO Country Codenexmo.number.getPhonePricing(product, countryCode, callback);
product
- either voice
or sms
countryCode
- 2 letter ISO Country Codenexmo.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
Example:
nexmo.number.get({pattern:714,index:1,size:50,search_pattern:2},consolelog);
nexmo.number.search(countryCode,options,callback);
options
parameter is optional. They can be one of the following :
pattern
search_pattern
features
index
size
For more details on what the above options mean refer to the Nexmo API documentation
Example:
nexmo.number.search('US',{pattern:3049,index:1,size:50,features:'VOICE',search_pattern:2},consolelog);
nexmo.number.buy(countryCode, msisdn, callback);
nexmo.number.cancel(countryCode, msisdn, callback);
nexmo.number.update(countryCode, msisdn, params, callback);
params is a dictionary of parameters per documentation
nexmo.account.updatePassword(<NEW_PASSWORD>,callback);
nexmo.updateSMSCallback(<NEW_CALLBACK_URL>,callback);
nexmo.account.updateDeliveryReceiptCallback(<NEW_DR_CALLBACK_URL>,callback);
nexmo.voice.sendTTSMessage(<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);
Run:
npm test
Or to continually watch and run tests as you change the code:
npm run-script test-watch
See examples/README.md.
Also see the Nexmo Node Quickstarts repo.
MIT - see LICENSE
[1.0.0]
applicationId
and privateKey
properties to first constructor parameter to support JWT generation.options.logger
to constructor 2nd parameter to allow adding customer logger.options.appendToUserAgent
to constructor 2nd paramater to append custom string to User-Agent
header sent to Nexmo.create
, get
, update
and delete
calls.create
, get
, update
and delete
calls.nexmo.message
nexmo.calls
nexmo.number
nexmo.verify
nexmo.numberInsight
nexmo.account
nexmo.voice
- legacy voice functionalityvar Nexmo = require('nexmo');
returns a class definition which should be created using the new
operator e.g. var nexmo = new Nexmo(args...);
.var nexmo = require('nexmo');
no longer exposes singleton functions offered by "easynexmo".FAQs
Nexmo REST API client for Node.js. API support for SMS, Voice Calls, Text-to-Speech, Numbers, Verify (2FA) and more.
The npm package nexmo receives a total of 6,319 weekly downloads. As such, nexmo popularity was classified as popular.
We found that nexmo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.