Vision blog

Exploring the OnApp API with Postman

Tags: , ,

Zack Grindall

Zack Grindall
Cloud Architect

OnApp has a comprehensive API that can be used to spin up new virtual machines, take snapshots and so much more. This guide will take you through the first steps of interacting with the API using an application called Postman.

Please note: This guide has been written specifically for OnApp v5.5, but should work with older versions of OnApp too.

 

 

1. Download the Postman app

Just follow this link to download the Postman app for Windows or Mac: https://www.getpostman.com/apps

 

2. Authenticate with the OnApp API

In the ‘Authorization’ tab, enter your OnApp username and password under the ‘Basic Auth’ dropdown.

 

3. Try something simple

Assuming demo.onapp.com is the hostname of your OnApp install, enter https://demo.onapp.com/version.json in the ‘Enter request URL’ field and select the method as ‘GET’.

You can now go ahead and click on ’Send’. This should result in the following:

 

Great! You’ve just authenticated with the OnApp API and got back the version number of your OnApp installation.

 

4. Now let’s try interacting with a virtual machine using the API

Replace the URL we entered earlier with https://demo.onapp.com/virtual_machines.json. Click on ‘Send’ again and you should receive a list of the virtual servers on your OnApp deployment.

We can delve deeper into a virtual machine using the API too. Let’s try – replacing the :id with a virtual machine identifier from the list you’ve just received – https://demo.onapp.com/virtual_machines/:id.xml

We can also reboot the virtual machine by changing the method to ‘POST’ and entering the following URL:
https://demo.onapp.com/virtual_machines/:id/reboot.json

Great! We’ve just obtained a list of virtual machines, delved deeper into a specific virtual machine and performed a reboot on it.

 

What else can you do?

That’s just the beginning. You can find a list of supported API calls by following this link:
https://docs.onapp.com/display/55API

We’ve also created some software development kits for popular programming languages (Ruby and PHP) and these are available on our GitHub page at https://github.com/onapp

There’s also a whole host of SDKs made by the GitHub community (including one for Golang) from alexzorin and you can get that here: https://github.com/alexzorin/onapp

In the next tutorial I’ll guide you through the steps to provision a virtual server, along with some code samples. Thanks!