API Center

Introduction

Last update:2022-06-30 15:13:13

Overview

1.Preface

Welcome to use CDN (content delivery network) service of Our system. Users are advised to follow instructions in this document when using API of CDN. Before using these interfaces, please ensure the apikey is enabled and CDN product manual and interface user agreement are fully understood.

2.Calling Method

To call CDN API, HTTP(s) requests with added corresponding request parameter need to be sent to its server address. Such requests include create, view, modify and delete. System will return processing results according to requests. To facilitate problem track and communications, Our system platform assigns one ID to every request/task. Field of x-cnc-request-id is added to response header and the request ID is returned to the customer. Warning: the updated function adds new json or xml character string on the foundation of original json or xml character string in the response from API, so developers from the using party please resolve requests with json and xml specifications, instead of treating them as specific character strings. Our system platform limits the visiting frequency of every customer, i.e., no more than 300 times of request in every 5 min.Each account has a recommended frequency of 30/5min for a single interface.utes. For special cases, please contact API liaison person of Our system.

3.Request Method

Communication Protocol
request communications, both HTTP and HTTPS are supported. If a higher level of security is needed, HTTPS is advised when sending requests.

.Request methods
Several methods actions are supported, including POST, GET, PUT and DELETE.

4.Common Parameters

Request parameters:

Request Header Required Description
Authorization Yes Authorization info, for example, user:password
Accept No BrowserAccepted MIME type, with json as the default returned format, such as 1. “Accept: application/json”, means the returned json format. 2. “Accept: application/xml”, means the returned xml format.
Content-Type Conditional What MIME category does the requested resource belong Notes: Needed when using POST or PUT method
Date Conditional Current local time, to calculate the field information of Authorization. The format should comply with RFC 1123 Specification, like Thu, 17 May 2012 19:37:58 GMT Notes: except x-cnc-date is used, or this field is compulsory.
x-cnc-date Conditional Current local time, to calculate the signature information of Authorization field. When Date cannot be set, this field can be used to set time. The format should comply with RFC 1123 Specification, like Thu, 17 May 2012 19:37:58 GMT
X-Time-Zone Conditional Time zone The format is the time zone offset representation relative to GMT, the regular constraint: ^GMT±:00$, the default value is GMT+ 08:00, for example, the East Eight Time Zone is GMT+08:00, and the West Eighth Zone is GMT-08:00; At the same time, it takes effect on the parameters of the entry and exit parameters; If the time parameter comes with a time zone, the time zone of the parameter itself is taken as the standard;

Response parameters:

Response Header Remarks
Accept MIME type that can be accepted by browsers
Content-Type What MIME category does the requested resource belong; Notes: Needed when using POST or PUT method
Date The format should comply with RFC 1123 Specification, like Thu, 17 May 2012 19:37:58 GMT

5.Authentication Method

Authentication information has to be contained in requests no matter either HTTP or HTTPS protocol is used in submitting these requests, as Our system platform required identity authentication for each request to the interface. In calling the interface, users need enter {user:password} and {Date header}(or x-cnc-date header). The password is generated with the GMT format of the date(for example, Thu, 10 Oct 2013 09:12:20 GMT) and the apikey(can be configured in SIWEB user center->User management->Profile) issued by Our system platform by the following method:

Calculation method of Codeblock 1 password

password=Base64(HMAC-SHA1(UTF-8(apikey), UTF-8(Date)))

Among these:

  1. Date and apikey have to be in UTF-8 encoding;
  2. The encryption algorithm used is Hash SHA1;
  3. The generated encrypted value is encoded with Base64 to generate the password. (For example, Qp7RBYI792wnpm/OFXK/DqeldAk=)

Our system platform compares the {Date} (or x-cnc-date header) in the interface requests with the local time of the platform. If the time difference is above 15 minutes, the request is ignored to avoid the re-sending of the expired message. Then get the password with the same encryption method and compare it with the user’s password. Requests with matched passwords are allowed and are denied if otherwise.

6.Code Examples

shell:Download
Java:Download
Python:Download
PHP:Download
Go:Download
.Net:Download
The sample code is for reference only, please use it according to the actual situation.

7.Response Formats

Success results
Success results are provided as blow. Samples of both json and xml are given.

Codeblock 7 json sample

HTTP/1.1  {2xx}
Date: Fri, 26 Oct 2012 06:33:26 GMT
Content-Type: application/xml;charset=utf-8
x-cnc-request-id:{id string auto generated by cloud server}  /* globally unique requestid */
{
  /* data of returned results  */
}
          

Codeblock 8 xml sample

HTTP/1.1   {2xx}
Date: Fri, 26 Oct 2012 06:33:26 GMT
Content-Type: application/xml;charset=utf-8
x-cnc-request-id:{id string auto generated by cloud server}  /* globally unique requestid */

<?xml version="1.0" encoding="UTF-8"?>
<!—results root-->
  <!—data of returned results-->
</!—results root-->

8.Failed results

Results data is not returned if the an error occurred in calling the interface Error cause can be positioned with “Error codes”. If an error occurred, HTTP request returns a 4xx or 5xx status code. The returned message contains the specific error code and error details. Besides, the request header also contains the globally unique ID: RequestId. If the error cause cannot be specified, please contact related technician from Our system and provide the RequestId to facilitate the tracking process.

Codeblock 9 json sample

HTTP/1.1   {4xx or 5xx}{error such as Access Denied or InternalError}
Date: Fri, 26 Oct 2012 06:33:26 GMT
Content-Type: application/xml;charset=utf-8
x-cnc-request-id:{id string auto generated by cloud server}  /* globally unique requestid */

{
    "code": "{the error   code, like MissingDateHeader}",
    "message": "{description, like Authorized request must have a Date or x-cnc-date header }"
}
      

Codeblock 10 xml sample

HTTP/1.1   {4xx or 5xx}{error such as Access Denied or InternalError}
Date: Fri, 26 Oct 2012 06:33:26 GMT
Content-Type: application/xml;charset=utf-8
x-cnc-request-id:{id string auto generated by cloud server}  /* this requestid is unique globally */

<?xml version="1.0" encoding="UTF-8"?>
<response>
  <code>{the error code, like MissingDateHeader}</code>
  <message>{description, like Authorized request must have a Date or x-cnc-date header}</message>
</response>
          

9.Error Code

HTTP status code message
401 WPLUS_InvalidHTTPAuthHeader The HTTP authorization header is bad
403 WPLUS_RequestTokenNotExistError request token not exist or expired
431 WPLUS_MatchApiNone there is no suitable api you request.
432 WPLUS_ApiPrivilegeError the account used is not authenticated using this api.
434 WPLUS_RequestExpired Request has expired.
435 WPLUS_AccountTooFrequence The account is too frequence.
436 WPLUS_IPTooFrequence The ip is too frequence.
437 WPLUS_AccountCapacityFull The api capacity is full.
438 WPLUS_APiTooFrequence The api is too frequence.
439 WPLUS_APiCapacityFull The api capacity is full.
440 WPLUS_AccountWhitelist remote ip not exists in account white list.
441 WPLUS_ApiWhitelist remote ip not exists in api white list.
443 WPLUS_ApiUnactive the api invoked is unactive.
446 WPLUS_AccountApiTooFrequence The account to the indicated api is too frequence.
447 WPLUS_APiTooConcurrent The api call is exceed thd concurrency threshold.
448 WPLUS_AccountTooConcurrent The account call is exceed thd concurrency threshold.
449 WPLUS_AccountApiTooConcurrent The account to the indicated api call is exceed thd concurrency threshold.
450 WPLUS_DateError date is error.
453 WPLUS_HystrixSocketConnectTimeout hystrix socket connect timeout!
501 WPLUS_SystemError system error!
503 WPLUS_InvokeBackendFail invoke backend fail!
530 WPLUS_InvalidArgument exception occured when read body(InputStream) from HttpServletRequest.
533 WPLUS_CollectAgentMakeDirError collectAgent call error:can not make folder.
534 WPLUS_CollectAgentMakeFileError collectAgent call error:can not make file.
535 WPLUS_RunShellError run shell error.
537 WPLUS_ProcessorHttpJobInvokerCallServiceError We encountered an internal error in CommonJobInvoker when call netty. Please try again.
555 WPLUS_HystrixSocketConnectError hystrix socket connect error!