Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

Flex Your Vultr Muscles In Windows & Mobile Apps With This Super-Easy API

Vultr API Hero Image

The great thing about Delphi is that it makes the tough jobs really easy. For instance, take the task of controlling cloud servers. By using Windows App development tools like RAD Studio Delphi’s cross-platform Firemonkey FMX framework, you can actually EASILY write a small application that allows your users to control cloud-based virtual machines, cloud computing instances, and even full-on “bare metal” cloud servers. What’s more; we’re going to do it in just FIFTEEN lines of code! There are almost no other programming languages around which offer this kind of power in so few lines of code.

What is Vultr?

Vultr is a commercial company offering a range of cloud-computing resources along the lines of Microsoft Azure, Amazon AWS, and DigitalOcean. We wrote about Digital Ocean before when we accessed their API in the post: Easily Automate The DigitalOcean API From Windows And Mobile

Just like DigitalOcean and many of the other cloud hosting companies, Vultr (https://www.vultr.com) also has a comprehensive collection of APIs to access from our applications.

What are we going to use the Vultr API for?

We’re going to produce some code which allows us to start, suspend/pause and end Vultr virtual instances. The basics of this technique can be used to control other vendor’s offerings too such a DigitalOcean Droplet because the access process to their APIs are very similar.

How do I set up an  Application with Vultr’s API?

In the previous DigitalOcean post we created a client API Rest connection to control the process of instance creation, deletion and to get all instances. For Vultr you can read the process in their documentation here, but of course you can check full source code here for how to code them.

Since in this article we’re discussing how to Start, Stop or Halt the Vultr instance we have created the first thing we should do Start a Vultr instance.

In the Vultr API documentation the examples says we can call their API as shown in the examples below:

Start a Vultr instance

[crayon-66e60c964f47f583865695/]

Reboot a Vultr instance

[crayon-66e60c964f487673665825/]

Reinstall a Vultr instance

[crayon-66e60c964f489208682479/]

Delphi Vultr API code example

Based on those examples, we can create the Delphi code as follows like so:

[crayon-66e60c964f48a382752672/]

It’s pretty succinct isn’t it? That’s the power of the Delphi language in action!

What does the Vultr’s Instance sample Windows application look like?

Since we are using Delphi Firemonkey framework you can right-click on the targets in the project Window and compile the code to other supported platforms. This example of using the Vultr API example works for Windows, Android, iOS, macOS, and Linux. Cross platform, Vultr instance control for all desktop and mobile operating systems, in fifteen lines of code.

Check out the full source code here: https://github.com/checkdigits/DelphiVultrInstance_example

Exit mobile version