Api

From SilverRack - Affordable VPS Hosting - Wiki

Jump to: navigation, search

Contents

API

The SilverRack API follows Rest-Ful principles. You can interact with the API through normal HTTP methods of GET, POST, PUT, and DELETE. The API accepts response formats in either JSON or XML. To specify the response, set the Accept header to application/json or application/xml.

In the examples below, any values surrounded with <> should be substituted with your own values.

Authentication

All API calls require authentication using your SilverRack Control Panel login credentials. Authentication is handled through Basic HTTP authentication. If the supplied credentials are invalid, this error is displayed:

{"ERROR":"Unauthorized"}

In the examples below, remember to substitute <username> and <password> with your own control panel login credentials.

VPS Commands

List of VPSs

curl -H "Content-Type:application/json" -H "Accept:application/json" https://<username>:<password>@silverrack.com/vpss
[{"ips": [{"ip": "208.53.44.219"}], "memory": 256, "diskspace": 10, "id": 4, "enabled": true, "bandwidth": 10, "ostemplate": "centos-4-i386-default", "hostname": "vps.bandofbrothersracing.com", "created": true}, {"ips": [{"ip": "216.194.127.245"}], "memory": 512, "diskspace": 20, "id": 100, "enabled": true, "bandwidth": 200, "ostemplate": "debian-4.0-i386-minimal", "hostname": "anotherhost.org", "created": true}, {"ips": [{"ip": "209.41.93.195"}], "memory": 256, "diskspace": 10, "id": 190,"enabled": true, "bandwidth": 100, "ostemplate": "ubuntu-8.04-i386-minimal", "hostname": "somehostname.com", "created": true}]

VPS Information

curl -H "Content-Type:application/json" -H "Accept:application/json" https://<username>:<password>@silverrack.com/vpss/<id>
{"ips": [{"ip": "209.41.93.195"}], "memory": 256, "diskspace": 10, "id": 190, "enabled": true, "bandwidth": 100, "ostemplate": "ubuntu-8.04-i386-minimal", "hostname": "somehostname.com", "created": true}

VPS Memory

curl -H "Content-Type:application/json" --request GET -H "Accept:application/json" https://<username>:<password>@silverrack.com/vpss/4/vz
{"mem_free": -181, "vzquota": "   resource          usage       softlimit      hardlimit    grace
  1k-blocks         618736        10485760       10485760         
     inodes          26022         5440680        5984750         ", 
"bean_counters": "    
93195:  kmemsize        4009171    4779188   11175424   12292966          0
            lockedpages           0          0        545        545          0
            privvmpages      111335     131153     131072     131072         36
            shmpages             18         18      49279      49279          0
            dummy                 0          0          0          0          0
            numproc              63         72        500        500          0
            physpages          9811      36660          0 2147483647          0
            vmguarpages           0          0      65536 2147483647          0
            oomguarpages       9811      36660      82133 2147483647          0
            numtcpsock           14         16        500        500          0
            numflock              9         14        435        478          0
            numpty                0          0         50         50          0
            numsiginfo            7          8       1024       1024          0
            tcpsndbuf        125216          0    1677141    3725141          0
            tcprcvbuf        180224     201644    1677141    3725141          0
            othersockbuf     165464     170636     838570    2886570          0
            dgramrcvbuf           0       8380     838570     838570          0
            numothersock        117        124        500        500          0
            dcachesize       253287     320193    2433739    2506752          0
            numfile            1248       1442       4352       4352          0
            dummy                 0          0          0          0          0
            dummy                 0          0          0          0          0
            dummy                 0          0          0          0          0
            numiptent            14         14        125        125          0",
 "mem_used": 437, "mem_total": 256}

Reboot VPS

curl -H "Content-Type:application/json" --request PUT -H "Accept:application/json" https://<username>:<password>@silverrack.com/vpss/<id>/reboot

Stop VPS

curl -H "Content-Type:application/json" -v --request PUT -H "Accept:application/json" https://<username>:<password>@silverrack.com/vpss/<id>/stop

Start VPS

curl -H "Content-Type:application/json" --request PUT -H "Accept:application/json" https://<username>:<password>@silverrack.com/vpss/<id>/start

DNS Commands

DNS Zones

curl -H "Content-Type:application/json" -H "Accept:application/json" https://<username>:<password>@silverrack.com/zones
[{"name": "silverrackvpshosting.com", "created_on": "2008/02/14 18:38:36 -0700", "server_updated": true, "updated_on": "2008/02/14 18:38:41 -0700", "id": 11, "user_id": 50}, {"name": "test123.com", "created_on": "2008/11/15 19:18:54 -0700", "server_updated": false, "updated_on": "2008/11/15 19:18:54 -0700", "id": 203, "user_id": 50}]

Zone Info

curl -H "Content-Type:application/json" -H "Accept:application/json" https://<username>:<password>@silverrack.com/zones/<id>
{"name": "silverrackvpshosting.com", "created_on": "2008/02/14 18:38:36 -0700", "server_updated": true, "updated_on": "2008/02/14 18:38:41 -0700", "id": 11, "user_id": 50}

New Zone

curl --request POST -H "Content-Type:application/json" -H "Accept:application/json" https://<username>:<password>@silverrack.com/zones

Response if new record has errors:

[["name", "can't be blank"], ["name", "please limit to alphanumeric characters, -, and ."]]
curl --request POST -H "Content-Type:application/json" -H "Accept:application/json" https://<username>:<password>@silverrack.com/zones -d "{\"zone\":{\"name\":\"test123\"}}"
{"name": "test123", "created_on": "2008/11/18 17:02:37 -0700", "server_updated": false, "updated_on": "2008/11/18 17:02:37 -0700", "id": 204, "user_id": 50}

After job has been processed, the server_updated flag is set to true:

{"name": "test123", "created_on": "2008/11/18 17:02:37 -0700", "server_updated": true, "updated_on": "2008/11/18 17:04:00 -0700", "id": 204, "user_id": 50}

Update Zone

curl --request PUT -H "Content-Type:application/json" -H "Accept:application/json" https://<username>:<password>@silverrack.com/zones/<id> -d "{\"zone\":{\"name\":\"test222\"}}"

New Zone Record

curl --request POST -H "Content-Type:application/json" -H "Accept:application/json" https://<username>:<password>@silverrack.com/zones/<id>/zone_records -d "{\"zone_record\":{\"record_type\":\"zrtype\",\"name\":\"zrname\",\"data\":\"zrdata\",\"extra\":\"zrextra\"}}"
{"name": "zrname", "created_on": "2008/11/20 18:47:20 -0700", "record_type": "zrtype", "zone_id": 204, "updated_on": "2008/11/20 18:47:20 -0700", "id": 774, "extra": "zrextra", "data": "zrdata"}

Zone Records for Zone

curl --request GET -H "Content-Type:application/json" -H "Accept:application/json" https://<username>:<password>@silverrack.com/zones/<id>/zone_records
[{"name": "zrname", "created_on": "2008/11/20 18:47:20 -0700", "record_type": "zrtype", "zone_id": 204, "updated_on": "2008/11/20 18:47:20 -0700", "id": 774, "extra": "zrextra", "data": "zrdata"}]

Show Zone Record

curl --request GET -H "Content-Type:application/json" -H "Accept:application/json" https://<username>:<password>@silverrack.com/zones/<zone_id>/zone_records/<zone_record_id>
{"name": "zrname", "created_on": "2008/11/20 18:47:20 -0700", "record_type": "zrtype", "zone_id": 204, "updated_on": "2008/11/20 18:47:20 -0700", "id": 774, "extra": "zrextra", "data": "zrdata"}

Update Zone Record

curl --request PUT -H "Content-Type:application/json" -H "Accept:application/json" https://<username>:<password>@silverrack.com/zones/<zone_id>/zone_records/<zone_record_id> -d "{\"zone_record\":{\"extra\":\"zrextra2\"}}"