API Basics

From INAP Dropzone API
Jump to: navigation, search

Each API module includes a set of functions which allow access to SingleHop's data. The Dropzone API is a RESTful API which makes use of GET and POST to receive commands and required data. When a data set is returned from the API it is return as a JSON object.

Some functions are dependent on others. For example, if you want to execute the server view command in the server module, you will need to provide SingleHop with the appropriate server ID. To find the right server ID you will first need to run the server list command. The response from the server list command will contain a list of all the servers that you have from SingleHop. From this list of server records you would find the server ID that is required by the server view command.


Contents

The API End Point

Each API web request should be directed at:

https://dropzone.singlehop.com/

Authentication

To authenticate with the Dropzone API you use your username and password for LEAP

When sending your username and password you will need to provide it with every command that you send.

https://USERNAME:PASSWORD@dropzone.singlehop.com/

Modules

For each module that you would like to interact with you will need to send the name of the module with the API endpoint.

https://USERNAME:PASSWORD@dropzone.singlehop.com/MODULE/

The LEAP API consists of 8 modules that can be accessed.

  1. Billing
  2. Order
  3. Server
  4. Service
  5. Solution
  6. Support
  7. Tandem
  8. User

Commands

Each API module consists of a variety of commands and on each page about the command you will find information on how to use the command and what data is required to be sent the API end point.

https://USERNAME:PASSWORD@dropzone.singlehop.com/MODULE/COMMAND/

Example Request & Response

The entire request put together would look like this;

https://USERNAME:PASSWORD@dropzone.singlehop.com/server/list/


The responses that are received from the API will be a JSON object. For instance the server list command would return;

stdClass Object(
  [success] => TRUE/FALSE
  [data] => Array(
    [0] => stdClass Object(
      [status] => Server status (online,offline,provisioning).
      [serverid] => Server ID number.
      [os] => Currently installed operating system.
      [hostname] => Server host name, as in "leap.singlehop.com".
      [ram] => Amount of RAM and type installed.
      [type] => Type of server (server,vmnode,vm).
      [cputype] => Type of CPU that is currently installed.
      [cpuspeed] => Speed of the installed CPU in GHz.
    )
  )
)

Every response returns 'success' and will always be either TRUE or FALSE, though many replies contain additional data. If success is FALSE then there will be an accompanying message parameter, 'error', which will be returned as well and explain what went wrong.

Using PHP to Connect

We suggest that you use cURL/libcurl to handle requests to Dropzone. Using cURL allows you to gather a ton of extra information about the request (as shown below) instead of just the response -- this could save a lot of time with troubleshooting and connection issues.

Array(
  [url] => http://dropzone.singlehop.com/server/list
  [content_type] => text/html; charset=UTF-8
  [http_code] => 200
  [header_size] => 172
  [request_size] => 117
  [filetime] => -1
  [ssl_verify_result] => 0
  [redirect_count] => 0
  [total_time] => 0.100578
  [namelookup_time] => 2.3E-05
  [connect_time] => 7E-05
  [pretransfer_time] => 0.000113
  [size_upload] => 0
  [size_download] => 28
  [speed_download] => 278
  [speed_upload] => 0
  [download_content_length] => 28
  [upload_content_length] => 0
  [starttransfer_time] => 0.100548
  [redirect_time] => 0
  [request_header] => GET /server/list HTTP/1.1
Authorization: Basic *****HIDDEN*********
Host: dropzone.singlehop.com
Accept: application/json
)

For more information relating to cURL for PHP, please visit http://php.net/manual/en/book.curl.php.

Personal tools