List Applications
In this code snippet you will see how to list all v1 and v2 Applications.
Example
You will need to ensure that the following replaceable values are set in the example code using any convenient method:
| Key | Description |
|---|---|
VONAGE_API_KEY | Your Vonage API key (see it on your dashboard). |
VONAGE_API_SECRET | Your Vonage API secret (also available on your dashboard). |
Write the code
Add the following to list-applications.sh:
curl -X "GET" "https://api.nexmo.com/v2/applications" \
-H 'Content-Type: application/json' \
-u "$VONAGE_API_KEY:$VONAGE_API_SECRET"Run your code
Save this file to your machine and run it:
Prerequisites
npm install @vonage/server-sdkCreate a file named list-applications.js and add the following code:
const { Vonage } = require('@vonage/server-sdk');
const vonage = new Vonage({
apiKey: VONAGE_API_KEY,
apiSecret: VONAGE_API_SECRET,
});Write the code
Add the following to list-applications.js:
const run = async () => {
try {
for await (const application of vonage.applications.listAllApplications()) {
console.log(application);
}
} catch (error) {
console.log(error);
}
};
run();Run your code
Save this file to your machine and run it:
Prerequisites
Add the following to build.gradle:
implementation 'com.vonage:server-sdk-kotlin:2.1.1'Create a file named ListApplications and add the following code to the main method:
val client = Vonage {
apiKey(VONAGE_API_KEY)
apiSecret(VONAGE_API_SECRET)
}Write the code
Add the following to the main method of the ListApplications file:
val applications = client.application.listAll()Run your code
We can use the application plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''Run the following gradle command to execute your application, replacing com.vonage.quickstart.kt.application with the package containing ListApplications:
Prerequisites
Add the following to build.gradle:
implementation 'com.vonage:server-sdk:9.3.1'Create a file named ListApplications and add the following code to the main method:
VonageClient client = VonageClient.builder()
.apiKey(VONAGE_API_KEY)
.apiSecret(VONAGE_API_SECRET)
.build();Write the code
Add the following to the main method of the ListApplications file:
ApplicationList applications = client.getApplicationClient().listApplications();
applications.getApplications().forEach(
application -> System.out.println(application.toJson())
);Run your code
We can use the application plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''Run the following gradle command to execute your application, replacing com.vonage.quickstart.application with the package containing ListApplications:
Prerequisites
Install-Package VonageCreate a file named ListApplications.cs and add the following code:
using Vonage;
using Vonage.Applications;
using Vonage.Request;
Add the following to ListApplications.cs:
var credentials = Credentials.FromApiKeyAndSecret(VONAGE_API_KEY, VONAGE_API_SECRET);
var client = new VonageClient(credentials);Write the code
Add the following to ListApplications.cs:
var request = new ListApplicationsRequest { Page = 1, PageSize = 10 };
var response = await client.ApplicationClient.ListApplicationsAsync(request);Prerequisites
composer require vonage/clientCreate a file named list-applications.php and add the following code:
Run your code
Save this file to your machine and run it:
Prerequisites
pip install vonage python-dotenvWrite the code
Add the following to list-applications.py:
from vonage import Auth, Vonage
from vonage_application import ListApplicationsFilter
client = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))
applications, next_page = client.application.list_applications(
filter=ListApplicationsFilter(page_size=10, page=1)
)
pprint(f'Applications:\n{applications}, \nNext page: {next_page}')Run your code
Save this file to your machine and run it:
Prerequisites
gem install vonageCreate a file named list-applications.rb and add the following code:
Run your code
Save this file to your machine and run it: