Cloud Platform API
Open Hosting’s HTTP API allows users to create drives, upload and download drive images and create and control virtual servers on our infrastructure. The API works in a straightforward ReST style, and we also provide a simple command line tool, drive upload tool and drive download tool for Unix or Windows Cygwin users to control our infrastructure from their own scripts without writing any code.
API Examples: Two Ways to Upload a Drive (AKA “Bring Your Own Server”)
Here is the full input and output of two examples of uploading your own server image using our simple command line tool and drive upload tool on Unix or Windows Cygwin (during the Cygwin installation be sure to install the cURL packages). Each command corresponds to a single API HTTP GET or POST, with the URL corresponding to the command line arguments, and the input and output data exactly as seen on the command line here.
Before we start you’ll need to set the API end-point. Alternatively, you can hard-code the value of OHURI in your local copy of the scripts.
export OHURI=https://api-east1.openhosting.com/
And, next set authentication credentials (from your account profile). Omit the secret key if you are running on a very old unix which leaks the content of your environment to other users via ‘ps e’. You will then be interactively prompted for your secret key by curl. Alternatively, you can hard-code the value of OHAUTH in your local copy of the scripts, but make sure they aren’t world-readable!
export OHAUTH=<user uuid>:<secret API key>
In these examples, we use the drive upload tool to automatically upload in gzipped chunks. A more basic upload with the raw API would be:
In the first example, we’ll create the drive in your account, then we’ll upload the image into the drive.
openhosting -c drives create << EOF | grep drive
> name TestDrive
> size 10000000
> EOF
drive 08c92dd5-70a0-4f51-83d2-835919d254df
openhosting -f image.raw drives 08c92dd5-70a0-4f51-83d2-835919d254df write
This second example creates a drive implicitly at the time the image is uploaded.
openhosting-upload image.raw
Created drive 08c92dd5-70a0-4f51-83d2-835919d254df of size 10000000
Uploading 2 chunks of 5242880 bytes: .. completed
Now, let’s boot a server from the drive, with 2000 core MHz and 1024 MB RAM
openhosting -c servers create << EOF
> name TestServer
> cpu 2000
> mem 1024
> ide:0:0 08c92dd5-70a0-4f51-83d2-835919d254df
> boot ide:0:0
> nic:0:model e1000
> nic:0:dhcp auto
> vnc:ip auto
> vnc:password XXXXXXXX
> EOF
server 85ef58c8-6f5d-4f7f-8f1c-0c19d45d7c1c
name TestServer
cpu 2000
smp 1
mem 1024
ide:0:0 08c92dd5-70a0-4f51-83d2-835919d254df
boot ide:0:0
nic:0:dhcp 91.203.56.132
nic:0:model e1000
rx 0
tx 0
vnc:ip 91.203.56.132
vnc:password XXXXXXXX
Using the API
The API is implemented in a ReST style, using the URL to specify an object and an action, HTTP GET to read state and HTTP POST to change state. In the description below, API URLs are relative to the stem https://api-east1.openhosting.com.
Users, drives and servers are identified by UUIDs, which are assigned by our infrastructure and passed as a string in the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.
Authentication
API calls must use HTTP Basic Authentication, specifying the user’s UUID as the username and their secret API key as the password. Both are available from the user’s account profile.
Data formats
The API can be used in either text/plain (default) or application/json modes. You should specify the type of input data with an HTTP Content-Type: header, and request a type for output with an HTTP Accept: header. text/plain is the default if no headers are set.
Click each box to reveal more information or you can expand or collapse all of the boxes:
| Collapse All



