
# 查询域名消耗统计
支持查询90天内的数据。
时间跨度最小支持1小时，最大不超过31天。
最多同时指定100个域名。
起始时间和结束时间需同时指定，为毫秒级时间戳，且必须为1小时或1天整时刻点。时间跨度\<7天，需为1小时整时刻点，如2020-07-01 08:00:00、2020-07-01 09:00:00；7天\<时间跨度\<31天，需为1天整时刻点，如2020-07-01 00:00:00、2020-07-02 00:00:00。
如果起始时间、结束时间不满足对应时间跨度的整时刻点，返回数据可能与预期不一致。
#### 功能介绍
用于查询指定时间区间、数据类型、指定域名的统计汇总容量。
#### URI
GET /v1.0/cdn/statistics/domain
#### 请求消息
**请求参数**
请求参数如[表1]所示。
 表1请求参数 
| 名称                    | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                               |
|:---|:---|:---|:---|
| start_time            | 否    | Long   | 查询起始时间戳（单位：毫秒）。                                                                                                                                                                                                                                                  |
| end_time              | 否    | Long   | 查询结束时间戳（单位：毫秒）。                                                                                                                                                                                                                                                  |
| domain_name           | 是    | String | 域名列表，多个域名以逗号（半角）分隔，如：www.test1.com,www.test2.com ，最多不超过20个域名。                                                                                                                                                                                                    |
| stat_type             | 是    | String | 参数类型支持：bw（带宽），flux（流量），bs_bw(回源带宽)，bs_flux（回源流量），bs_num(回源总数)，bs_fail_num(回源失败总数)，req_num(请求总数)，req_hit_rate（请求命中率），flux_hit_rate（流量命中率），bs_fail_rate（回源失败率），qps（每秒请求数），http_code_2xx(状态码2xx)，http_code_3xx(状态码3xx)，http_code_4xx(状态码4xx)，http_code_5xx(状态码5xx)。 |
| service_area          | 否    | String | mainland_china(中国大陆)，outside_mainland_china(中国大陆境外)，默认为mainland_china,回源指标bs_flux，bs_bw，bs_fail_rate,回源指标不区分服务范围，该参数对回源指标无效。                                                                                                                                     |
| enterprise_project_id | 否    | String | 当用户开启企业项目功能时，该参数生效，表示查询资源所属项目，"all"表示所有项目。注意：当使用子账号调用接口时，该参数必传。                                                                                                                                                                                                  |
   
**请求示例**
请求路径示例
```
GET https://cdn.myhuaweicloud.com/v1.0/cdn/statistics/domain?start_time=1513094400000&end_time=1513180799346&domain_name=example1.example2.com,example3.example4.com&interval=300&stat_type=flux&enterprise_project_id=0
```
#### 响应消息
**响应参数**
响应参数如表[表2]所示。
 表2响应参数 
| 名称     | 参数类型   | 描述                                                    |
|:---|:---|:---|
| domain | Object | 域名统计数据对象汇总。详细说明见[表3]。 |
   
**domain参数说明**
domain参数说明如[表3]所示。
 表3domain参数说明 
| 名称           | 参数类型    | 描述                                                                          |
|:---|:---|:---|
| start_time   | Integer | 查询起始时间戳（单位：毫秒）。                                                             |
| end_time     | Integer | 查询结束时间戳（单位：毫秒）。                                                             |
| value        | Integer | 总流量。（流量单位：Byte，带宽单位：bps）                                                    |
| stat_type    | String  | 统计类型。                                                                       |
| domain_name  | String  | 域名。                                                                         |
| service_area | String  | mainland_china(中国大陆)，outside_mainland_china(中国大陆境外)。回源指标不区分服务范围，该参数对回源指标无效。 |
   
**响应示例**
```
{
    "domain": 
     [
        {
            "value": 197400,
            "start_time": 1513094400000,
            "end_time": 1513180799346,
            "stat_type": "flux",
            "domain_name": "example1.example2.com",
            "service_area": "mainland_china"
        },
        {
            "value": 42825,
            "start_time": 1513094400000,
            "end_time": 1513180799346,
            "stat_type": "flux",
            "domain_name": "example3.example4.com",
            "service_area": "mainland_china"
        }
    ]
}
```
#### 状态码
状态码请参见[状态码](https://support.huaweicloud.com/api-cdn/cdn_02_0070.html)。
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-cdn/ErrorCode.html)。
