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:
./list-applications.sh
Prerequisites
npm install @vonage/server-sdk
Create a file named get-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
}, {
debug: true
});
Write the code
Add the following to get-applications.js
:
vonage.applications.get({}, (error, result) => {
if(error) {
console.error(error);
}
else {
console.log(result);
}
}, true);
Run your code
Save this file to your machine and run it:
node get-applications.js
Prerequisites
Add the following to `build.gradle`:
compile 'com.vonage:client:6.2.0'
Create a class 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
class:
ApplicationClient applicationClient = client.getApplicationClient();
ApplicationList applications = applicationClient.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
:
gradle run -Pmain=com.vonage.quickstart.application.ListApplications
Prerequisites
Install-Package Vonage
Create a file named ListApplications.cs
and add the following code:
using Vonage;
using Vonage.Request;
using Vonage.Applications;
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 = client.ApplicationClient.ListApplications(request);
Prerequisites
composer require vonage/client
Create a file named list-applications.php
and add the following code:
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
$client = new \Vonage\Client(new \Vonage\Client\Credentials\Container($basic));
Write the code
Add the following to list-applications.php
:
foreach ($client->applications() as $application) {
echo sprintf("%s: %s\n", $application->getId(), $application->getName());
}
Run your code
Save this file to your machine and run it:
php list-applications.php
Prerequisites
pip install vonage
Create a file named list-applications.py
and add the following code:
client = vonage.Client(
key=VONAGE_API_KEY,
secret=VONAGE_API_SECRET
)
Write the code
Add the following to list-applications.py
:
response = client.application_v2.list_applications()
Run your code
Save this file to your machine and run it:
python3 list-applications.py
Prerequisites
gem install vonage
Create a file named list-applications.rb
and add the following code:
client = Vonage::Client.new(
api_key: VONAGE_API_KEY,
api_secret: VONAGE_API_SECRET
)
Write the code
Add the following to list-applications.rb
:
response = client.applications.list
response._embedded.applications.each do |application|
puts "#{application.name}: #{application.id}"
end
Run your code
Save this file to your machine and run it:
ruby list-applications.rb