Vonage Server SDK for Node.js
This is the Node.JS Server SDK for Vonage APIs. To use it you will need a Vonage account. Sign up for free at vonage.com.
For full API documentation refer to developer.nexmo.com.
Installation
With NPM
npm install @vonage/server-sdk@next
With Yarn
yarn add @vonage/server-sdk@next
Constructor
const { Vonage } = require('@vonage/server-sdk');
const vonage = new Vonage({
apiKey: API_KEY,
apiSecret: API_SECRET,
applicationId: APP_ID,
privateKey: PRIVATE_KEY_PATH,
signatureSecret: SIGNATURE_SECRET,
signatureMethod: SIGNATURE_METHOD
}, options);
apiKey
- API Key from Vonage API. If applicationId
and privateKey
are present, apiKey
is optional.apiSecret
- API SECRET from Vonage API. If applicationId
and privateKey
are present, apiSecret
is optional.applicationId
- (optional) The Vonage API Application ID to be used when creating JWTs.privateKey
- (optional) The Private Key to be used when creating JWTs. You can specify the key as any of the following:
- A Buffer containing the file contents.
- A String containing the path to the key file on disk.
- A String containing the key itself.
signatureSecret
- (optional) API signature secret from Vonage API, used for signing SMS message requestssignatureMethod
- (optional) signature method matching the one you gave Vonage API, used for signing SMS message requests. Must be one of "md5hash", "md5", "sha1", "sha256", or "sha512"options
- (optional) Additional options for the constructor.
Options are:
{
debug: true|false,
appendToUserAgent: string,
logger: {
log: function() {level, args...}
info: function() {args...},
warn: function() {args...}
},
timeout: integer,
apiHost: string,
restHost: string,
videoHost: string,
}
Promises
Most methods that interact with the Vonage API uses Promises. You can either resolve these yourself, or use await
to
wait for a response.
const resp = await vonage.sms.send({to: '15552220000', from: '15559992222', 'This is a test'});
Testing
Run:
npm run test
Or to continually watch and run tests as you change the code:
npm run test-watch
Examples
See the Vonage Node Quickstarts repo.
Supported APIs
The following is a list of Vonage APIs and whether the Node Server SDK provides support for them:
API | API Release Status | Supported? |
---|
Account API | General Availability | ✅ |
Alerts API | General Availability | ✅ |
Application API | General Availability | ✅ |
Audit API | Beta | ❌ |
Conversation API | Beta | ❌ |
Dispatch API | Beta | ❌ |
External Accounts API | Beta | ❌ |
Media API | Beta | ❌ |
Messages API | Beta | ❌ |
Number Insight API | General Availability | ✅ |
Number Management API | General Availability | ✅ |
Pricing API | General Availability | ✅ |
Redact API | Developer Preview | ❌ |
Reports API | Beta | ❌ |
SMS API | General Availability | ✅ |
Verify API | General Availability | ✅ |
Voice API | General Availability | ✅ |