IP查询
查询IP是否我司,如是则查询该IP归属哪个地区及省份。
Open API在线调试功能提供可视化界面在线调试API、支持生成代码示例、快速检索查看API文档等能力。前往调试
参数名称 | 类型 | 必填 | 描述 |
---|---|---|---|
ip | 是 | 需要查询的IP列表,单次最大20个(联系技术支持可调上限) |
参数名称 | 类型 | 描述 |
---|---|---|
result | 结果 | |
ip | IP地址 | |
isCdnIp | 是否我司CDN的IP 1.true 是我司CDN的节点IP 2.false 不是我司CDN的节点IP | |
country | 归属国家地区;不是我司CDN的节点,不返回;如未规划的则返回未知。 | |
province | 归属省份;不是我司CDN的节点,不返回;如未规划的则返回未知; | |
city | 归属城市;不是我司CDN的节点,不返回;如未规划的则返回未知; | |
isp | 归属运营商;不是我司CDN的节点,不返回;如未规划的则返回未知。 |
错误代码(code) | 描述(message) | HTTP状态码 | 语义 |
---|---|---|---|
MissingBody | This operation requires a body. Ensure that the body is present and the Content-Type header is set. | 400 | 请求体没有传递 |
NotAcceptable | The accept header specified in your request is not acceptable. | 400 | Accept请求头不支持,接口仅支持json和xml格式,默认为json格式 |
InvalidHTTPRequest | There was an error in the body of your HTTP request. | 400 | 请求体格式错误 |
NumberLimitExceeded | The request was rejected because the number of ip(actual) exceeds the limit (expect). | 400 | 查询的ip个数超出限制 |
PARAM_INVALID | param: ip is null or invalid. | 400 | 参数ip不符合规范 |
InternalError | We encountered an internal error. Please try again. | 500 | 系统发生错误 |
#!/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/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 } ] }