You can call the DescribeDomainUsageData operation to query the usage data of specific CDN domains under a specific region.

Note
  • You can query usage data for a maximum of 100 CDN domains per request. Multiple domain names are separated with commas (,). If you do not specify any CDN domains, usage data of all CDN domains under your account is returned.
  • Usage data includes network traffic measured in bytes, bandwidth measured in bits/s, and the number of requests.

Debugging

Alibaba Cloud provides OpenAPI Explorer to simplify API usage. You can use OpenAPI Explorer to search for APIs, call APIs, and dynamically generate SDK example code.

Request parameters

Parameter Type Required Description
Action String  Yes The operation that you want to perform. Set this parameter to DescribeDomainUsageData.
DomainName String No
  • The name of the CDN domain. If you do not specify this parameter, the data of all your CDN domains are returned.
  • You can specify multiple domain names and separate them with commas (,).
StartTime String Yes The beginning of the time range where the usage data is queried. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC. The minimum data sampling interval is 5 minutes.
EndTime String Yes The end of the time range where the usage data is queried. The end time must be later than the start time. The maximum time range that can be queried is 31 days. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC.
DataProtocol String No The protocol of the data to be queried. Valid values: https, http, and all. Default value: all.
Type String No The content type for which the data is generated. Default value: all. Valid values:
  • static: static content
  • dynamic: dynamic content
  • all: all content
Area String No The region ID. Valid values: CN, OverSeas, AP1, AP2, AP3, NA, SA, EU, MEAA, and all. Default value: CN, which indicates Mainland China.
Field String Yes The type of the data to be queried. Valid values: bps, traf, and acc. If you set this parameter to acc, the Area parameter is not supported.
Interval String No The data sampling interval. Unit: seconds. Valid values: 300, 3600, and 86400.
Note
  • If you set the Interval parameter to 300, you can query data of up to the last six months, and the maximum time range that can be queried is three days.
  • If you set the Interval parameter to 3600 or 86400, you can query data of up to the last 12 months.
  • If you do not specify the Interval parameter, the maximum time range that can be queried is one month, and the data sampling interval depends on the specified time range.
    • Less than four days: one hour.
    • No less than four days: one day.

Parameter combinations

The following table lists the mappings between the billed items and parameter values. For more information about the calling method, see Sample request.

Billed item Valid value of DataProtocol Valid value of Type Valid value of Field Valid value of Area
Network traffic all. You can also leave this parameter empty. all. You can also leave this parameter empty. traf CN, OverSeas, AP1, AP2, AP3, NA, SA, EU, or MEAA.
Bandwidth all. You can also leave this parameter empty. all. You can also leave this parameter empty. bps CN, OverSeas, AP1, AP2, AP3, NA, SA, EU, or MEAA.
Number of HTTPS requests for static content https static acc all
Number of HTTP requests for dynamic content http dynamic acc all
Number of HTTPS requests for dynamic content https dynamic acc all

Response parameters

Parameter Type Description
DomainName String The CDN domain name.
DataInterval String The data sampling interval, in seconds.
StartTime DateTime The beginning of the time range where the data was queried.
EndTime DateTime The end of the time range where the data was queried.
Type String The type of the content for which the data was returned.
Area String The acceleration region.
UsageDataPerInterval UsageData[] The detailed usage data for each interval.

Parameters in UsageData

Parameter Type Description
TimeStamp String The timestamp of the data.
PeakTime String If the Field parameter in the request is set to bps, this parameter returns the time when the bandwidth peaks. Otherwise, this parameter returns the same value as the TimeStamp parameter.
Value String The amount of data that was used, in bytes.

Examples

Sample request

  • Query network traffic usage in Mainland China.
    http://cdn.aliyuncs.com?Action=DescribeDomainUsageData&DomainName=example.com
    &StartTime=2015-12-10T20:00:00Z
    &EndTime=2015-12-10T22:00:00Z
    &Field=traf
    &Area=CN
    &<Common request parameters>
  • Query bandwidth usage in Europe.
    http://cdn.aliyuncs.com?Action=DescribeDomainUsageData&DomainName=example.com
    &StartTime=2015-12-10T20:00:00Z
    &EndTime=2015-12-10T22:00:00Z
    &Field=bps
    &Area=EU
    &<Common request parameters>
  • Query the number of HTTPS requests for static content.
    http://cdn.aliyuncs.com?Action=DescribeDomainUsageData&DomainName=example.com
    &StartTime=2015-12-10T20:00:00Z
    &EndTime=2015-12-10T22:00:00Z
    &Type=static
    &DataProtocol=https
    &Field=acc
    &Area=all
    &<Common request parameters>
  • Query the number of HTTP requests for dynamic content.
    http://cdn.aliyuncs.com?Action=DescribeDomainUsageData&DomainName=example.com
    &StartTime=2015-12-10T20:00:00Z
    &EndTime=2015-12-10T22:00:00Z
    &Type=dynamic
    &DataProtocol=http
    &Field=acc
    &Area=all
    &<Common request parameters>
  • Query the number of HTTPS requests for dynamic content.
    http://cdn.aliyuncs.com?Action=DescribeDomainUsageData&DomainName=example.com
    &StartTime=2015-12-10T20:00:00Z
    &EndTime=2015-12-10T22:00:00Z
    &Type=dynamic
    &DataProtocol=https
    &Field=acc
    &Area=all
    &<Common request parameters>

Sample success response

JSON format

{
    "DomainName": "example.com",
    "DataInterval": "300",
    "UsageDataPerInterval": {
        "DataModule": [
            {
                "TimeStamp": "2015-12-10T20:00:00Z",
                "PeakTime": "2015-12-10T20:05:00Z",
                "Value": "423304182"
            },
            {
                "TimeStamp": "2015-12-10T21:00:00Z",
                "PeakTime": "2015-12-10T21:30:00Z",
                "Value": "454680793"
            }
        ]
    },
    "RequestId": "B955107D-E658-4E77-B913-E0AC3D31693E",
    "StartTime": "2015-12-10T20:00Z",
    "EndTime": "2015-12-10T21:00Z",
    "Area": "CN",
    "Type": "traf"
}

Error codes

Error code Error message HTTP status code Description
Throttling Request was denied due to request throttling. 503 The error message returned because the request was denied due to throttling.
IllegalOperation Illegal domain, operation is not permitted. 403 The error message returned because the specified domain name is invalid.
OperationDenied Your account does not open CDN service yet. 403 The error message returned because CDN has not been activated for your account.
OperationDenied Your CDN service is suspended. 403 The error message returned because CDN has been suspended for your account.
InvalidDomain.NotFound The domain provided does not belong to you. 404 The error message returned because the specified domain does not exist or does not belong to you.
InvalidDomain.Offline The domain provided is offline. 404 The error message returned because the specified domain is disabled.
ServiceBusy The specified Domain is configuring, please retry later. 403 The error message returned because the specified domain is being configured. Try again later.
InvalidDomain.Configure_failed Failed to configure the provided domain. 500 The error message returned because the system has failed to configure the specified domain.
InvalidParameter Invalid Parameter. 400 The error message returned because the parameters are invalid.
InvalidParameterProduct Invalid Parameter Product. 400 The error message returned because the specified Product parameter is invalid.
InvalidParameterArea Invalid Parameter Area. 400 The error message returned because the specified Area parameter is invalid.
InvalidParameterField Invalid Parameter Field. 400 The error message returned because the specified Field parameter is invalid.
InvalidParameterStartTime Invalid Parameter StartTime. 400 The error message returned because the specified StartTime parameter is invalid.
InvalidParameterEndTime Invalid Parameter EndTime. 400 The error message returned because the specified EndTime parameter is invalid.
InvalidTimeRange StartTime and EndTime range should less than 1 month. 400 The error message returned because the duration specified by the StartTime and EndTime parameters exceeds the maximum value of 31 days.
InvalidParameterInterval Invalid Parameter Interval. 400 The error message returned because the specified Interval parameter is invalid.