Download OpenAPI specification:Download
「さくらのVPS」が提供するAPIの利用方法とサンプルを公開しております。
「さくらのVPS」が提供するAPIはまだ一部の機能に制限しておりますが、順次機能を追加していく予定です。
APIを利用するためには、認証のための「APIキー」が必要です。
APIキーはVPSコントロールパネルから発行ができます。
このドキュメント内では発行したAPIキーの例としてSAMPLETOKENSAMPLETOKENSAMPLETOK
と記載します。
https://secure.sakura.ad.jp/vps/api/v7/(エンドポイント)
となります。Authorization: Bearer SAMPLETOKENSAMPLETOKENSAMPLETOK
を指定します。# リクエストのサンプル
curl -H 'Authorization: Bearer SAMPLETOKENSAMPLETOKENSAMPLETOK' \
'https://secure.sakura.ad.jp/vps/api/v7/servers'
APIへのリクエストが成功したか失敗したかは、HTTPレスポンスのステータスコードで判断が可能です。
結果 | ステータスコード |
---|---|
成功 (要求を受け付けた) | 2xx |
失敗(要求が受け付けられなかった) | 4xx, 5xx |
リクエストに成功すると、HTTPレスポンスのボディにはコンテンツ(データ)がJSON形式(UTF-8)で入っています。 ただしコンテンツ(データ)を返さないリクエストの場合はボディは空です。
# コンテンツ(データ)のサンプル
{
"id": 1,
"name": "sample_data"
}
リクエストに失敗すると、HTTPレスポンスのボディには失敗した理由などがJSON形式(UTF-8)で入っています。
# 失敗した場合のボディのサンプル
{
"code": "not_found",
"message": "見つかりませんでした"
}
429
となりますpage | integer |
per_page | integer |
switch | integer switchのid 対象のスイッチに接続されているサーバーに絞り込む |
zone_code | string Enum: "tk1" "tk2" "tk3" "os1" "os2" "os3" "is1" ゾーンコードで絞り込む
|
service_type | string Enum: "linux" "windows" サービスタイプで絞り込む 例:
|
ipv4_address | string Example: ipv4_address=192.0.2.0 IPアドレスで絞り込む |
monitoring_resource_id | integer サーバー監視リソースIDで絞り込む |
sort | string Enum: "service_code" "-service_code" "name" "-name" "storage_size_gibibytes" "-storage_size_gibibytes" "memory_mebibytes" "-memory_mebibytes" "cpu_cores" "-cpu_cores" "hostname" "-hostname" "ipv6_hostname" "-ipv6_hostname" "ipv4_address" "-ipv4_address" "ipv6_address" "-ipv6_address" "zone_code" "-zone_code" "ipv4_ptr" "-ipv4_ptr" "ipv6_ptr" "-ipv6_ptr" データの並び順。項目名の頭に
|
search | string 名前、説明文、ホスト名、ipv4アドレス、ipv6アドレス、サービスコードから部分一致検索 |
{- "results": [
- {
- "id": 0,
- "name": "string",
- "description": "string",
- "service_type": "linux",
- "service_status": "on_trial",
- "cpu_cores": 2,
- "memory_mebibytes": 1024,
- "storage": [
- {
- "port": 0,
- "type": "ssd",
- "size_gibibytes": 100
}
], - "zone": {
- "code": "tk1",
- "name": "石狩第1"
}, - "options": [
- "SQL Server Web Edition"
], - "version": "v5",
- "ipv4": {
- "address": "198.51.100.2",
- "netmask": "255.255.254.0",
- "gateway": "198.51.100.1",
- "nameservers": [
- "203.0.113.1"
], - "hostname": "example.jp",
- "ptr": "example.jp"
}, - "ipv6": {
- "address": "2001:e42:102:1501:153:121:89:107",
- "prefixlen": 64,
- "gateway": "fe80::1",
- "nameservers": [
- "2001:e42::1"
], - "hostname": "example.jp",
- "ptr": "example.jp"
}, - "contract": {
- "plan_code": 3439,
- "plan_name": "さくらのVPS(v5) 1G IK01",
- "service_code": "100000000000"
}, - "power_status": "power_on"
}
], - "count": 100,
}
{- "id": 0,
- "name": "string",
- "description": "string",
- "service_type": "linux",
- "service_status": "on_trial",
- "cpu_cores": 2,
- "memory_mebibytes": 1024,
- "storage": [
- {
- "port": 0,
- "type": "ssd",
- "size_gibibytes": 100
}
], - "zone": {
- "code": "tk1",
- "name": "石狩第1"
}, - "options": [
- "SQL Server Web Edition"
], - "version": "v5",
- "ipv4": {
- "address": "198.51.100.2",
- "netmask": "255.255.254.0",
- "gateway": "198.51.100.1",
- "nameservers": [
- "203.0.113.1"
], - "hostname": "example.jp",
- "ptr": "example.jp"
}, - "ipv6": {
- "address": "2001:e42:102:1501:153:121:89:107",
- "prefixlen": 64,
- "gateway": "fe80::1",
- "nameservers": [
- "2001:e42::1"
], - "hostname": "example.jp",
- "ptr": "example.jp"
}, - "contract": {
- "plan_code": 3439,
- "plan_name": "さくらのVPS(v5) 1G IK01",
- "service_code": "100000000000"
}, - "power_status": "power_on"
}
server_id required | integer サーバーID |
name required | string 名前 |
description required | string 説明 |
{- "name": "string",
- "description": "string"
}
{- "id": 0,
- "name": "string",
- "description": "string",
- "service_type": "linux",
- "service_status": "on_trial",
- "cpu_cores": 2,
- "memory_mebibytes": 1024,
- "storage": [
- {
- "port": 0,
- "type": "ssd",
- "size_gibibytes": 100
}
], - "zone": {
- "code": "tk1",
- "name": "石狩第1"
}, - "options": [
- "SQL Server Web Edition"
], - "version": "v5",
- "ipv4": {
- "address": "198.51.100.2",
- "netmask": "255.255.254.0",
- "gateway": "198.51.100.1",
- "nameservers": [
- "203.0.113.1"
], - "hostname": "example.jp",
- "ptr": "example.jp"
}, - "ipv6": {
- "address": "2001:e42:102:1501:153:121:89:107",
- "prefixlen": 64,
- "gateway": "fe80::1",
- "nameservers": [
- "2001:e42::1"
], - "hostname": "example.jp",
- "ptr": "example.jp"
}, - "contract": {
- "plan_code": 3439,
- "plan_name": "さくらのVPS(v5) 1G IK01",
- "service_code": "100000000000"
}, - "power_status": "power_on"
}
server_id required | integer サーバーID |
force | boolean Default: false 強制停止を行うか |
{- "force": false
}
{- "code": "not_authenticated",
- "message": "認証情報が含まれていません。"
}
server_id required | integer サーバーID |
hostname | string Default: "example.jp" ホスト名 |
{- "hostname": "example.jp"
}
{- "code": "invalid",
- "message": "Invalid input.",
- "errors": {
- "foo": [
- {
- "code": "required",
- "message": "この項目は必須です"
}
]
}
}
server_id required | integer サーバーID |
{- "results": [
- {
- "id": 0,
- "device": "eth0",
- "connectable_to_global_network": true,
- "connect_to": "global",
- "mac": "9C:A3:BA:00:00:00",
- "switch_id": 1
}
], - "count": 100,
}
server_id required | integer サーバーID |
interface_id required | integer サーバーインターフェースID |
{- "id": 0,
- "device": "eth0",
- "connectable_to_global_network": true,
- "connect_to": "global",
- "mac": "9C:A3:BA:00:00:00",
- "switch_id": 1
}
server_id required | integer サーバーID |
interface_id required | integer サーバーインターフェースID |
switch_id required | integer or null スイッチID |
{- "switch_id": 1
}
{- "id": 0,
- "device": "eth0",
- "connectable_to_global_network": true,
- "connect_to": "global",
- "mac": "9C:A3:BA:00:00:00",
- "switch_id": 1
}
server_id required | integer サーバーID |
hostname | string Default: "example.jp" ホスト名 |
{- "hostname": "example.jp"
}
{- "code": "invalid",
- "message": "Invalid input.",
- "errors": {
- "foo": [
- {
- "code": "required",
- "message": "この項目は必須です"
}
]
}
}
server_id required | integer サーバーID |
type required | string Enum: "vga" "cirrus" ビデオデバイスの種類 |
{- "type": "vga"
}
{- "type": "vga"
}
{- "cpu_performance_limit": "enabled",
- "network_bandwidth_limit": "enabled",
- "outbound_port_25_blocking": "enabled",
- "storage_iops_limit": "enabled"
}
page | integer |
per_page | integer |
switch | integer switchのid 対象のスイッチに接続されているサーバーに絞り込む |
zone_code | string Enum: "tk1" "tk2" "tk3" "os1" "os2" "os3" "is1" ゾーンコードで絞り込む
|
sort | string Enum: "service_code" "-service_code" "name" "-name" "storage_size_gibibytes" "-storage_size_gibibytes" "ipv4_address" "-ipv4_address" "zone_code" "-zone_code" データの並び順。項目名の頭に
|
{- "results": [
- {
- "id": 0,
- "name": "string",
- "description": "string",
- "service_status": "in_preparation",
- "setting_status": "done",
- "storage": [
- {
- "type": "ssd",
- "size_gibibytes": 100
}
], - "zone": {
- "code": "tk1",
- "name": "石狩第1"
}, - "ipv4": {
- "address": "198.51.100.2",
- "netmask": "255.255.254.0"
}, - "contract": {
- "plan_code": 3439,
- "plan_name": "さくらのVPS(v5) NFS 200GB OS03",
- "service_code": "100000000000"
}, - "power_status": "power_on"
}
], - "count": 100,
}
nfs_server_id required | integer NFSサーバーID |
{- "id": 0,
- "name": "string",
- "description": "string",
- "service_status": "in_preparation",
- "setting_status": "done",
- "storage": [
- {
- "type": "ssd",
- "size_gibibytes": 100
}
], - "zone": {
- "code": "tk1",
- "name": "石狩第1"
}, - "ipv4": {
- "address": "198.51.100.2",
- "netmask": "255.255.254.0"
}, - "contract": {
- "plan_code": 3439,
- "plan_name": "さくらのVPS(v5) NFS 200GB OS03",
- "service_code": "100000000000"
}, - "power_status": "power_on"
}
nfs_server_id required | integer NFSサーバーID |
name required | string 名前 |
description required | string 説明 |
{- "name": "string",
- "description": "string"
}
{- "id": 0,
- "name": "string",
- "description": "string",
- "service_status": "in_preparation",
- "setting_status": "done",
- "storage": [
- {
- "type": "ssd",
- "size_gibibytes": 100
}
], - "zone": {
- "code": "tk1",
- "name": "石狩第1"
}, - "ipv4": {
- "address": "198.51.100.2",
- "netmask": "255.255.254.0"
}, - "contract": {
- "plan_code": 3439,
- "plan_name": "さくらのVPS(v5) NFS 200GB OS03",
- "service_code": "100000000000"
}, - "power_status": "power_on"
}
nfs_server_id required | integer NFSサーバーID |
address required | string ipv4アドレス |
netmask required | string ネットマスク |
{- "address": "string",
- "netmask": "string"
}
{- "code": "invalid",
- "message": "Invalid input.",
- "errors": {
- "foo": [
- {
- "code": "required",
- "message": "この項目は必須です"
}
]
}
}
nfs_server_id required | integer NFSサーバーID |
switch_id required | integer or null スイッチID |
{- "switch_id": 1
}
{- "id": 0,
- "device": "eth0",
- "connect_to": "switch",
- "mac": "9C:A3:BA:00:00:00",
- "switch_id": 1
}
name required | string 名前 |
description required | string 説明 |
zone_code required | string Enum: "tk2" "tk3" "os3" "is1" ゾーンコード
|
{- "name": "string",
- "description": "string",
- "zone_code": "tk2"
}
{- "id": 0,
- "name": "string",
- "description": "string",
- "switch_code": "string",
- "zone": {
- "code": "tk2",
- "name": "石狩第1"
}, - "server_interfaces": [ ],
- "nfs_server_interfaces": [ ],
- "external_connection": null
}
page | integer |
per_page | integer |
zone_code | string Enum: "tk1" "tk2" "tk3" "os1" "os2" "os3" "is1" ゾーンコードで絞り込む
|
interface | integer interfaceのid 対象のインターフェースに接続されているスイッチに絞り込む |
sort | string Enum: "name" "-name" "zone" "-zone" "interfaces_count" "-interfaces_count" データの並び順。項目名の頭に
|
search | string 名前と説明文から部分一致検索 |
{- "results": [
- {
- "id": 0,
- "name": "string",
- "description": "string",
- "switch_code": "string",
- "zone": {
- "code": "tk1",
- "name": "石狩第1"
}, - "server_interfaces": [
- 0
], - "nfs_server_interfaces": [
- 0
], - "external_connection": {
- "service_code": "100000000000",
- "type": "cloud",
- "services": [
- {
- "service_category": "cloud",
- "service_name": "クラウド東京第1ゾーン",
- "switch_code": "111111111111"
}
]
}
}
], - "count": 100,
}
{- "id": 0,
- "name": "string",
- "description": "string",
- "switch_code": "string",
- "zone": {
- "code": "tk1",
- "name": "石狩第1"
}, - "server_interfaces": [
- 0
], - "nfs_server_interfaces": [
- 0
], - "external_connection": {
- "service_code": "100000000000",
- "type": "cloud",
- "services": [
- {
- "service_category": "cloud",
- "service_name": "クラウド東京第1ゾーン",
- "switch_code": "111111111111"
}
]
}
}
switch_id required | integer スイッチID |
name required | string 名前 |
description required | string 説明 |
{- "name": "string",
- "description": "string"
}
{- "id": 0,
- "name": "string",
- "description": "string",
- "switch_code": "string",
- "zone": {
- "code": "tk1",
- "name": "石狩第1"
}, - "server_interfaces": [
- 0
], - "nfs_server_interfaces": [
- 0
], - "external_connection": {
- "service_code": "100000000000",
- "type": "cloud",
- "services": [
- {
- "service_category": "cloud",
- "service_name": "クラウド東京第1ゾーン",
- "switch_code": "111111111111"
}
]
}
}
{- "results": [
- {
- "id": 0,
- "name": "string",
- "description": "string",
- "license_required": true
}
], - "count": 100,
}