CDN加速

查询IP的归属

更新时间:2020-09-01 11:22:14

适用产品:通用功能

接口描述

查询IP是否我司,如是则查询该IP归属哪个地区及省份。

请求参数

JSON
参数名称类型必填描述
ipArray需要查询的IP列表,单次最大20个(联系技术支持可调上限)

返回参数

JSON
参数名称类型描述
ipstringIP地址
isCdnIpBoolean是否我司CDN的IP 1.true 是我司CDN的节点IP 2.false   不是我司CDN的节点IP
countrystring归属国家地区;不是我司CDN的节点,不返回;如未规划的则返回未知。
provincestring归属省份;不是我司CDN的节点,不返回;如未规划的则返回未知;
citystring归属城市;不是我司CDN的节点,不返回;如未规划的则返回未知;
ispstring归属运营商;不是我司CDN的节点,不返回;如未规划的则返回未知。

错误码

错误代码(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请求体格式错误
NumberLimitExceededThe   request was rejected because the number of ip(actual) exceeds the limit   (expect).400查询的ip个数超出限制
PARAM_INVALIDparam:   ip is null or invalid.400参数ip不符合规范
InternalErrorWe   encountered an internal error. Please try again.500系统发生错误

示例

JSON
XML
示例说明
请求示例
复制
#!/bin/bash
# 请将示例中的(-H "X-Time-Zone") 参数设置为您希望在返回结果中获得的时区
# 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/tools/ip-info" \
  -X "POST" \
-H "X-Time-Zone:GMT+08:00" \
  -u "$username:$password" \
  -H "Date: $date" \
  -H "Accept: application/json" \
  -d '{
          "ip":   ["1.1.1.1", "2.2.2.2"]
  }'
返回示例
复制
{
      "result":[
          {
                "ip":"1.1.1.1",
              "isCdnIp":false
          },
          {
                "ip":"2.2.2.2",
                "country":"中国",
                "province":"湖南",
              "city":"衡阳",
                "isp":"电信",
              "isCdnIp":true
          }
      ]
  }