SDKs overview
Nexmo, operating under the Vonage brand since its acquisition, offers a suite of Software Development Kits (SDKs) to simplify interaction with its communication APIs. These SDKs are designed to provide developers with a higher-level abstraction over the raw HTTP requests and JSON responses of the Vonage Communication APIs. By encapsulating API calls, authentication, and error handling, the SDKs enable developers to integrate features such as SMS, voice, video, and user verification more efficiently into their applications.
The official SDKs are maintained by Vonage and cover a range of popular programming languages. They are regularly updated to reflect changes and additions to the underlying APIs, ensuring compatibility and access to new features. Developers can typically find comprehensive documentation and code examples within the Vonage Developer Portal for each SDK.
Using an SDK can reduce development time and potential errors compared to making direct HTTP requests. For instance, an SDK might automatically handle API key management, request signing, and response parsing, allowing developers to focus on application logic rather than communication protocol details. This approach is common among API providers, as seen with Stripe's client libraries or Google Cloud's SDKs, which aim to streamline integration for their respective services.
Official SDKs by language
Vonage provides official SDKs for several programming languages, each tailored to the specific language's conventions and package management systems. These SDKs are the recommended method for interacting with Vonage APIs due to their active maintenance and comprehensive feature support. The table below outlines the primary official SDKs available:
| Language | Package Name | Install Command Example | Maturity |
|---|---|---|---|
| Node.js | @vonage/server-sdk |
npm install @vonage/server-sdk |
Production Ready |
| Python | vonage |
pip install vonage |
Production Ready |
| PHP | vonage/client |
composer require vonage/client |
Production Ready |
| .NET | Vonage |
dotnet add package Vonage |
Production Ready |
| Java | com.vonage:client |
Add to pom.xml or build.gradle |
Production Ready |
| Ruby | vonage |
gem install vonage |
Production Ready |
Each SDK provides specific methods corresponding to the various Vonage APIs, such as the SMS API, Voice API, and Verify API. Developers can find detailed API-specific usage instructions and examples in the Vonage developer documentation.
Installation
Installation of Vonage SDKs typically follows standard practices for each programming ecosystem. Below are examples for installing the official SDKs:
Node.js
To install the Node.js SDK, use npm or yarn:
npm install @vonage/server-sdk
# or
yarn add @vonage/server-sdk
Python
The Python SDK can be installed via pip:
pip install vonage
PHP
For PHP, Composer is used to manage dependencies:
composer require vonage/client
.NET
The .NET SDK is installed using the .NET CLI or NuGet Package Manager:
dotnet add package Vonage
# or via NuGet Package Manager Console
Install-Package Vonage
Java
For Java projects, add the Vonage client as a dependency in your pom.xml (for Maven) or build.gradle (for Gradle).
Maven (pom.xml)
<dependency>
<groupId>com.vonage</groupId>
<artifactId>client</artifactId>
<version>7.x.x</version> <!-- Use the latest version -->
</dependency>
Gradle (build.gradle)
implementation 'com.vonage:client:7.x.x' // Use the latest version
Ruby
The Ruby SDK is available as a gem:
gem install vonage
After installation, ensure that you have your Vonage API Key and API Secret, which are available from your Vonage Dashboard, to authenticate your SDK calls. These credentials are essential for making authenticated requests to the Vonage APIs.
Quickstart example
This quickstart demonstrates how to send an SMS message using the Vonage Node.js SDK. This example assumes you have Node.js installed and have obtained your API Key and API Secret from your Vonage account.
Prerequisites:
- Node.js installed.
- Vonage API Key and API Secret.
- A Vonage virtual number (purchased from your Vonage dashboard).
Steps:
- Install the Node.js SDK:
- Create a new JavaScript file (e.g.,
send-sms.js) and add the following code: - Replace
"YOUR_API_KEY","YOUR_API_SECRET","YOUR_VONAGE_NUMBER", and"RECIPIENT_NUMBER"with your actual credentials and numbers. - Run the script from your terminal:
npm install @vonage/server-sdk
const { Vonage } = require('@vonage/server-sdk');
const vonage = new Vonage({
apiKey: "YOUR_API_KEY",
apiSecret: "YOUR_API_SECRET"
});
const from = "YOUR_VONAGE_NUMBER"; // Your Vonage virtual number
const to = "RECIPIENT_NUMBER"; // The recipient's phone number
const text = "Hello from Nexmo/Vonage SDK!";
async function sendSMS() {
try {
const resp = await vonage.sms.send({
to: to,
from: from,
text: text
});
console.log('Message sent successfully:');
console.log(resp.messages[0]);
} catch (err) {
console.error('There was an error sending the message.');
console.error(err);
}
}
sendSMS();
node send-sms.js
Upon successful execution, you should see a confirmation message in your console indicating the SMS was sent. This example demonstrates the basic pattern for initializing the SDK and making an API call, a pattern that extends to other Vonage APIs like the Messages API for omnichannel communication.
Community libraries
While Vonage maintains a comprehensive set of official SDKs, the broader developer community also contributes libraries and tools that can interact with the Vonage APIs. These community-developed resources can sometimes offer specialized functionality, alternative language support, or integrations with specific frameworks not explicitly covered by the official SDKs.
Community libraries are typically found on package managers like GitHub, npm, PyPI, or RubyGems, and their quality and maintenance levels can vary. Developers considering using a community library should:
- Check for active maintenance: Look at the project's commit history, issue tracker, and release frequency.
- Review documentation: Ensure the library has clear and sufficient documentation for usage and integration.
- Examine source code: Verify that the code quality meets your project's standards and that it correctly implements API interactions and security best practices, especially concerning OAuth 2.0 or other authentication methods.
- Consider support: Official SDKs usually come with direct support from the vendor, whereas community libraries rely on community contributions for troubleshooting.
The Vonage Developer Portal often highlights popular community contributions or provides guidelines for building client libraries, encouraging community engagement. However, for core API interactions and mission-critical applications, the official SDKs are generally recommended due to their direct support and alignment with the latest API versions and features, as detailed in the official Vonage SDK documentation.