Public API¶
[Update: January 23, 2018]
This page explains public API that can be used for the [Web Accelerator].
The API can be used by sending an API request via the curl command, etc.
Introduction¶
How to Use¶
It is necessary to issue API key from the SAKURA Cloud control panel. API key can be issued from the API key management section of the control panel.
Cautions¶
API URL¶
https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/
Unlike SAKURA Cloud API, please always specify :code: is1a (Ishikari Zone No. 1) for the web accelerator API.
Authentication¶
At the web accelerator API, you can use basic authentication and digest authentication using API key and secret token in the same way as SAKURA Cloud API. The API key and secret token can be issued and confirmed at API key management of the control panel.
JSON¶
JSON is used for the request parameters and the response format.
SSL Only¶
Only access via https is possible.
UTF-8¶
UTF-8 is used for the character code.
Date format¶
ISO8601 is used for the datetime format. Output is as shown below.
2013-01-14T09:30:00+09:00
About the response format¶
Unlike SAKURA Cloud API, the web accelerator API does not support response formation via an X-Sakura-API-Beautify request header.
Cautions¶
- Please do not perform intensive access during a short period of time.
API response¶
The API returns the HTTP response codes listed below. The specific meaning of each API is listed in each description.
Status code | Content |
---|---|
200 OK | The request was processed correctly and a response was returned. |
400 Bad Request | Request parameters are invalid. |
401 Unauthorized | Authentication failed. |
403 Forbidden | There is no access permission to the resource. Example: An attempt was made to access the site of another member. |
404 Not Found | The resource does not exist. Example: The resource “/site/000000000001/certificate” was accessed even though the site “000000000001” does not exist. |
500 Internal Server Error | An internal error occurred. Example: Database connection failed. |
Shared specifications for request parameters¶
The web accelerator API does not support shared specifications for request parameters of SAKURA Cloud API.
API for acquiring site list¶
URL | /site |
---|---|
Method | GET |
Content | Acquire a site list. |
Example of request¶
GET https://secure.sakura.ad.jp/cloud/zone/is1a/api/webaccel/1.0/site HTTP/1.1
リクエストボディ
なし
レスポンスボディ
{
"Total": 2,
"From": 0,
"Count": 2,
"Sites": [
{
"Index": 0,
"ID": "000000000001",
"Name": "サイト1",
"DomainType": "own_domain",
"Domain": "cdn1.example.com",
"Subdomain": "0f5cty4g.user.webaccel.jp",
"ASCIIDomain": "cdn1.example.com",
"Origin": "198.51.100.1",
"HostHeader": "cdn2.example.com",
"Status": "enabled",
"CreatedAt": "2015-11-13T02:56:01+09:00",
"HasCertificate": true,
"HasOldCertificate": false,
"GibSentInLastWeek": 80,
"CertValidNotBefore": 1457568000000, // 2016-03-10 00:00:00 +0000 UTC の通算ミリ秒
"CertValidNotAfter": 1526558400000, // 2018-05-17 12:00:00 +0000 UTC の通算ミリ秒
},
{
"Index": 1,
"ID": "000000000002",
"Name": "サイト2",
"DomainType": "subdomain",
"Domain": "さくら.example.jp",
"Subdomain": "0uwjbk35.user.webaccel.jp",
"ASCIIDomain": "xn--y8jl1n.example.jp",
"Origin": "198.51.100.2",
"HostHeader": "cdn2.example.com",
"Status": "disabled",
"CreatedAt": "2015-11-13T02:57:01+09:00",
"HasCertificate": true,
"HasOldCertificate": false,
"GibSentInLastWeek": 180,
"CertValidNotBefore": 1457568000000, // 2016-03-10 00:00:00 +0000 UTC の通算ミリ秒
"CertValidNotAfter": 1526558400000, // 2018-05-17 12:00:00 +0000 UTC の通算ミリ秒
}
],
"is_ok": true
}
Example of curl (Linux)¶
$ curl --user "Access Token":"Access Token Secret" \
https://secure.sakura.ad.jp/cloud/zone/is1a/api/webaccel/1.0/site
API for updating certificate and private key information¶
URL | /site/:siteid/certificate |
---|---|
Method | PUT |
Content | Update certificate and private key information for the current generation. The previous generation is configured with certificate and private key information prior to the update. |
Example of request¶
PUT https://secure.sakura.ad.jp/cloud/zone/is1a/api/webaccel/1.0/site/000000000001/certificate HTTP/1.1
リクエストボディ
{
"Certificate": {
"CertificateChain": "-----BEGIN CERTIFICATE-----・・・・・",
"Key": "-----BEGIN RSA PRIVATE KEY-----・・・・・"
}
}
秘密鍵を変更しない場合は "Key" の項目は省略可能です
レスポンスボディ
{
"Certificate": {
"Current":{
"ID": "1",
"SiteID": "000000000001",
"CertificateChain": "-----BEGIN CERTIFICATE-----・・・・・",
"Key": "-----BEGIN RSA PRIVATE KEY-----・・・・・",
"CreatedAt": "2015-11-13T02:57:01+09:00",
"UpdatedAt": "2015-11-14T02:57:01+09:00"
},
"Old": [
{
"ID": "1",
"SiteID": "000000000001",
"CertificateChain": "-----BEGIN CERTIFICATE-----・・・・・",
"CreatedAt": "2015-11-13T02:57:01+09:00",
"UpdatedAt": "2015-11-14T02:57:01+09:00"
}
]
}
"Success": true,
"is_ok": true
}
Example of curl (Linux)¶
$ curl --user "Access Token":"Access Token Secret" \
-X PUT -d '{"Certificate": {"Certificate": "-----BEGIN CERTIFICATE-----・・・・・"}}' \
https://secure.sakura.ad.jp/cloud/zone/is1a/api/webaccel/1.0/site/000000000001/certificate
API for deleting all caches¶
URL | /deleteallcache |
---|---|
Method | POST |
Content | Delete all caches in a single site. |
Example of request¶
POST https://secure.sakura.ad.jp/cloud/zone/is1a/api/webaccel/1.0/deleteallcache HTTP/1.1
リクエストボディ
{
"Site": {
"Domain": "example.com"
}
}
ドメインには公開ドメイン名を指定
レスポンスボディ
{
"Success": true,
"is_ok": true
}
Example of curl (Linux)¶
$ curl --user "Access Token":"Access Token Secret" \
-X POST -d '{"Site": {"Domain": "example.com"}}' \
https://secure.sakura.ad.jp/cloud/zone/is1a/api/webaccel/1.0/deleteallcache
API for deleting individual caches¶
URL | /deletecache |
---|---|
Method | POST |
Content | Delete a cache. |
Example of request¶
POST https://secure.sakura.ad.jp/cloud/zone/is1a/api/webaccel/1.0/deletecache HTTP/1.1
リクエストボディ
{
"URL": [
"http://example.com/url1",
"http://example.com/url2",
"http://example.com/url3"
]
}
URLは最大100個まで指定可能
レスポンスボディ
{
"Results": [
{ "URL": "http://example.com/url1", "Status": 200, "Result": "OK" },
{ "URL": "http://example.com/url2", "Status": 404, "Result": "Not Found" },
{ "URL": "http://example.com/url3", "Status": 403, "Result": "Forbidden" },
{ "URL": "http://example.com/url4", "Status": 500, "Result": "Internal Server Error" }
],
"Success": true,
"is_ok": true
}
Example of curl (Linux)¶
$ curl --user "Access Token":"Access Token Secret" \
-X POST -d '{"URL": ["http://www.example.com/wp-content/uploads/2016/7/example.jpg"]}' \
https://secure.sakura.ad.jp/cloud/zone/is1a/api/webaccel/1.0/deletecache