文档中心 API文档 查询域名国家地区流量和带宽

查询域名国家地区流量和带宽

更新时间:2023-05-24 14:14:40

适用产品

全站加速、PCDN、DMS、移动加速、应用安全解决方案、政企安全加速解决方案、IPv6一体化解决方案、下载分发、网页加速、WSS、WEB应用防火墙、应用安全加速解决方案、BotGuard爬虫管理、区块链安全加速解决方案、电商安全加速解决方案、动态加速、金融安全加速解决方案、IPv6安全加速解决方案、点播分发、DDoS云清洗、直播分发

接口描述

查询各域名流量带宽数据在各个国家地区的分布情况。建议查询24小时前的数据。

推荐使用 Open API在线调试

Open API在线调试功能提供可视化界面在线调试API、支持生成代码示例、快速检索查看API文档等能力。前往调试

请求参数

Body 参数

参数名称类型必填描述
dateFrom
String开始时间 1. 时间格式为yyyy-MM-ddTHH:mm:ss+08:00,例如,2016-12-02T10:00:00+08:00(为北京时间2016年12月2日10点0分0秒); 2. 不能大于当前时间 3. 最多可获取最近半年(183天)的数据。
dateTo
String结束时间: 1. 时间格式2016-12-02T10:00:00+08:00 2. 结束时间需大于开始时间,结束时间如果大于当前时间,取当前时间。 3. dateFrom,dateTo二者都未传,默认查询过去的24小时;如仅有一个未传,抛异常 4. 允许查询最大时间间隔:7天,即dateFrom和dateTo相差不能超过7天(可联系技术支持调整)。
dataInterval
String数据粒度: 1. 支持5m(5分钟粒度),1d(天粒度) 2. 不传默认为5m
domain
List域名: 1. 可传递域名数量上限默认为20个(可联系技术支持调整); 2. 自动过滤掉非法域名(如传递非法域名,会被过滤掉,查询结果只返回合法域名的数据)。
countryCode
List国家地区代号: 1. 不传默认查询全部国家地区; 2. 可传递的值详见概览页国家地区列表说明。
groupBy
List1. 可选值domain、country、aggregatedOversea,可传入单个或多个值,其中不能同时传aggregatedOversea 和 country; 2. 有传入则按照该维度展示明细数据: 1.domain:按照域名维度进行分组展示; 2.domain:country:按照国家维度进行分组展示; 3.aggregatedOversea:按照国内 和 海外维度进行分组展示 3. 返回结果层级顺序固定,入参顺序不影响返回结果顺序。例如:groupBy: [domain,country]与groupBy: [country,domain]返回结果一样。

返回参数

Body 参数

参数名称类型描述
result
List结果
domain
String域名
countryData
List
countryCode
String国家地区代号
countryName
String国家地区名称
flowSum
String国家地区流量汇总:单个国家地区流量在查询时段内的流量汇总值,计量单位MB,保留2位小数
flowPercentage
String国家地区流量占比:单个国家地区流量在查询时段内的流量值的占比(百分比),保留2位小数
flowData
List
timestamp
String1. 查询的数据粒度为5m时,格式为yyyy-MM-dd HH:mm;每一个时间片数据值代表的是前一个时间粒度范围内的数据值。一天开始的时间片是yyyy-MM-dd 00:05,最后一个时间片是(yyyy-MM-dd+1) 00:00。2. 返回开始时间和结束时间包含的时间片。
value
String流量值,计量单位MB,保留2位小数
bandwidth
String带宽值,单位Mbps,保留2位小数

错误码

错误代码(code)描述(message)HTTP状态码语义
MissingBodyThis   operation requires a body. Ensure that the body is present and the   Content-Type header is set.400请求体没有传递
NotAcceptableThe   accept header specified in your request is not acceptable.400Accept请求头不支持,接口仅支持json和xml格式,默认为json格式
InvalidHTTPRequestThere   was an error in the body of your HTTP request.400请求体格式错误
InvalidDatePeriodThe   date specified is invalid.400dateFrom或dateTo不符合规范
DateSpanErrorYou   cannot specify a period greater than 7.400dateFrom和dateTo相差超过7天
NumberLimitExceededThe   request was rejected because the number of domain(actual) exceeds the limit   (expect).400传递的域名个数超出限制
PARAM_INVALIDparam:   groupBy is null or invalid.400参数groupBy不符合规范
InternalErrorWe   encountered an internal error. Please try again.500系统发生错误
PARAM_INVALIDparam: domain is null or invalid.400参数domain不符合规范
PARAM_INVALIDparam: countryCode is null or invalid.400参数countryCode不符合规范
MissingBodyThis   operation requires a body. Ensure that the body is present and the   Content-Type header is set.400请求体没有传递
NotAcceptableThe   accept header specified in your request is not acceptable.400Accept请求头不支持,接口仅支持json和xml格式,默认为json格式
InvalidHTTPRequestThere   was an error in the body of your HTTP request.400请求体格式错误
InvalidDatePeriodThe   date specified is invalid.400dateFrom或dateTo不符合规范
DateSpanErrorYou   cannot specify a period greater than 7.400dateFrom和dateTo相差超过7天
NumberLimitExceededThe   request was rejected because the number of domain(actual) exceeds the limit   (expect).400传递的域名个数超出限制
PARAM_INVALIDparam:   groupBy is null or invalid.400参数groupBy不符合规范
InternalErrorWe   encountered an internal error. Please try again.500系统发生错误
PARAM_INVALIDparam: domain is null or invalid.400参数domain不符合规范
PARAM_INVALIDparam: countryCode is null or invalid.400参数countryCode不符合规范

示例

XML
JSON(按域名及国家分组)
JSON(按域名及国内外分组)
XML
请求示例
复制代码 复制成功
#!/bin/bash
# Please remember to change the param (-H "X-Time-Zone") in this demo to the TimeZone you want in response

  username='example_username'
  apiKey='example_apiKey'
  date=`env LANG="en_US.UTF-8" date -u "+%a, %d %b %Y %H:%M:%S   GMT"`
  password=`echo -en "$date" | openssl dgst -sha1 -hmac $apiKey   -binary | openssl enc -base64`
  curl -i --url   "https://open.chinanetcenter.com/api/report/flow/domain-country" \
  -X "POST" \
-H "X-Time-Zone:GMT+08:00" \
  -u "$username:$password" \
  -H "Date: $date" \
  -H "Accept: application/xml" \
  -d '{
      "dateFrom":   "2018-04-19T00:00:00+08:00",
      "dateTo":   "2018-04-20T00:00:00+08:00",
      "domain": [
          "www.test1.com",
        "www.test2.com"
      ],
      "dataInterval":   "5m",
      "countryCode": [
          "cn",
          "jp"
      ],
      "groupBy": [
          "domain",
          "country"
      ]
  }'
返回示例
复制代码 复制成功
<?xml version="1.0"   encoding="UTF-8"?>
  <report>
     <result>
        <domain-country-data>
           <domain>www.test1.com</domain>
           <country-data>
                <country-measure-data>
                   <country-code>jp</country-code>
                   <country-name>日本</country-name>
                   <flow-sum>2.00</flow-sum>
                   <flow-percentage>16.67%</flow-percentage>
                 <flow-data>
                    <detail>
                         <timestamp>2018-04-19 00:10</timestamp>
                         <value>2.00</value>
                    </detail>
                 </flow-data>
              </country-measure-data>
                <country-measure-data>
                   <country-code>cn</country-code>
                   <country-name>中国大陆</country-name>
                   <flow-sum>10.00</flow-sum>
                   <flow-percentage>83.33%</flow-percentage>
                 <flow-data>
                    <detail>
                         <timestamp>2018-04-19 00:05</timestamp>
                         <value>1.00</value>
                    </detail>
                    <detail>
                         <timestamp>2018-04-19 00:10</timestamp>
                       <value>2.00</value>
                    </detail>
                 </flow-data>
                </country-measure-data>
           </country-data>
        </domain-country-data>
        <domain-country-data>
             <domain>www.test2.com</domain>
           <country-data>
                <country-measure-data>
                   <country-code>cn</country-code>
                   <country-name>中国大陆</country-name>
                   <flow-sum>1.00</flow-sum>
                   <flow-percentage>100.00%</flow-percentage>
                 <flow-data>
                    <detail>
                         <timestamp>2018-04-19 00:05</timestamp>
                         <value>1.00</value>
                    </detail>
                 </flow-data>
                </country-measure-data>
           </country-data>
        </domain-country-data>
     </result>
  </report>
本篇文档内容对您是否有帮助?
有帮助
我要反馈
提交成功!非常感谢您的反馈,我们会继续努力做到更好!