跳到正文

IP地理位置信息查询

接口说明

该接口是一个IP地理位置信息查询服务,能够对IP地理位置信息进行查询。支持输入IP值,根据不同的查询实体返回信息,返回信息包括国家、省份、城市、经度坐标、纬度坐标、注册机构、网络类型等地理位置相关信息。

请求地址

https://api.f.360.cn/custom/iplib/internal/v3/ip_geo/:ip

请求方法

POST

请求参数

参数名类型位置是否必填示例值
ipstringpath是34.107.19.249

响应参数

名称类型示例值描述
errnoInt200状态码
msgstringsuccess结果说明
resultobject查询结果
result.network_locationobject位置
result.network_location.accuracyinteger6精度
result.network_location.asstringCHINANET-Qinghai-AS-APAS组织名称
result.network_location.asninteger140061ASN
result.network_location.citystring海西蒙古族藏族自治州城市
result.network_location.countrystring中国国家
result.network_location.districtstring朝阳区区县
result.network_location.latitudestring37.86306600纬度坐标
result.network_location.longitudestring8.68747300经度坐标
result.network_location.operatorstring中国电信中国电信
result.network_location.time_zonestring时区
result.network_location.provincestring青海省省份/州
result.summaryobject摘要
result.summary.anonymous_typestringVPN匿类型踪
result.summary.user_typestring该IP的用户类型
result.summary.geo_infoobject地理信息
result.summary.geo_info.asstringCHINANET-Qinghai-AS-APAS组织名称
result.summary.geo_info.asninteger140061ASN
result.summary.geo_info.citystring海西蒙古族藏族自治州城市
result.summary.geo_info.continentstring亚洲洲
result.summary.geo_info.countrystring中国国家
result.summary.geo_info.districtstring朝阳区区县
result.summary.geo_info.operatorstring中国电信IP注册机构
result.summary.geo_info.areacodestringCN国家编码
result.summary.geo_info.provincestring青海省省份/州
result.summary.network_typeArray(string)已使用IP的网络类型
result.user_infoobject用户信息
result.user_info.user_typestring该IP的用户类型
result.user_info.userstring该IP的用户

请求示例

支持cUrl、Python、Java、PHP、Go语言的请求,示例如下

#!/usr/bin/env bash
set -euo pipefail

APPID=""  # apikey
SECRET=""  # salt
URL="https://api.f.360.cn/custom/iplib/internal/v3/ip_geo/34.107.19.249"
BODY='{}'

NONCE=$(printf '%08d' $((RANDOM % 100000000)))
TIMESTAMP=$(date +%s)
BODY_MD5=$(printf '%s' "$BODY" | openssl dgst -md5 -hex | awk '{print $NF}')
SIGNATURE=$(printf '%s' "${BODY_MD5}${APPID}${NONCE}${TIMESTAMP}${SECRET}" | openssl dgst -md5 -hex | awk '{print $NF}')
SIGNATURE=${SIGNATURE:16}

curl --location --request POST "$URL" \
  --header "Content-Type: application/json" \
  --header "X-360-Key: ${APPID}" \
  --header "X-360-Nonce: ${NONCE}" \
  --header "X-360-Timestamp: ${TIMESTAMP}" \
  --header "X-360-Signature: ${SIGNATURE}" \
  --data "${BODY}"

响应示例

业务正常响应

{
    "errno": 2000,
    "from": "360威胁情报中心",
    "invalid": [],
    "msg": "success",
    "result": {
        "summary": {
            "geo_info": {
                "continent": "欧洲",
                "country": "德国",
                "areacode": "DE",
                "province": "黑森州",
                "city": "美因河畔法兰克福",
                "district": "",
                "asn": 396982,
                "as": "GOOGLE-CLOUD-PLATFORM",
                "operator": "谷歌公司"
            },
            "network_type": ["已使用"],
            "user_type": "",
            "anonymous_type": ""
        },
        "network_location": {
            "country": "德国",
            "province": "黑森州",
            "city": "美因河畔法兰克福",
            "district": "",
            "accuracy": 4,
            "time_zone": "UTC+1",
            "longitude": "8.68747300",
            "latitude": "50.11080900",
            "asn": 396982,
            "as": "GOOGLE-CLOUD-PLATFORM",
            "operator": "谷歌公司"
        },
        "user_info": {
            "user_type": "",
            "user": ""
        }
    }
}

业务异常响应

{
    "errno": 2000,
    "from": "360威胁情报中心",
    "invalid": [
        "266.266.1.1"
    ],
    "msg": "success",
    "result": {}
}