A collection of APIs for obtaining IP address information


Sometimes during development, the front end occasionally needs to pass the client's ip address, and you often have to write your own method to achieve it. Today I will share some APIs with you to free your hands. The following method can obtain the external network IP of the client.

1. ip.cn query network to obtain the current client IP

API地址: https://www.ip.cn/api/index?ip&type=0

return value:

{
    
    
  "rs": 1,
  "code": 0,
  "address": "美国  加利福尼亚 旧金山 ",
  "ip": "172.70.211.115",
  "isDomain": 0
}

Two, ip query network to obtain the current client IP

API地址:https://2023.ipchaxun.com/

return value:

{
    
    
  "ret": "ok",
  "ip": "220.202.233.76",
  "data": [
    "中国",
    "湖南",
    "长沙",
    "岳麓",
    "联通",
    "410000",
    "0731"
  ]
}

3. Baidu obtains IP address information

API地址:https://opendata.baidu.com/api.php?query=[ip地址串]&co=&resource_id=6006&oe=utf8

return value

{
    
    
  "status": "0",
  "t": "",
  "set_cache_time": "",
  "data": [
    {
    
    
      "ExtendedLocation": "",
      "OriginQuery": "172.0.90.2",
      "appinfo": "",
      "disp_type": 0,
      "fetchkey": "172.0.90.2",
      "location": "美国密西西比",
      "origip": "172.0.90.2",
      "origipquery": "172.0.90.2",
      "resourceid": "6006",
      "role_id": 0,
      "shareImage": 1,
      "showLikeShare": 1,
      "showlamp": "1",
      "titlecont": "IP地址查询",
      "tplt": "ip"
    }
  ]
}

4. This site obtains the current client IP information

API地址:https://searchplugin.csdn.net/api/v1/ip/get?ip=[IP地址串,不填时为查询本机客户端IP]

return value

{
    
    
  "code": 200,
  "msg": "success",
  "data": {
    
    
    "address": "中国 湖南 长沙 联通",
    "ip": "220.202.233.76"
  }
}

5. Other platforms obtain IP address information interface

1. Interface of Evan technology platform

  1. Get client IP address API
    https://www.ipplus360.com/getIP
{
    
    
  "success": true,
  "code": 200,
  "msg": "获取用户端IP成功",
  "data": "23.142.224.204"
}
  1. Get client IP location information API
    https://www.ipplus360.com/getLocation
{
    
    
  "success": true,
  "code": 200,
  "msg": "获取客户端地理位置成功",
  "data": "CaliforniaFremont"
}

注意两个API是分开的,第二个API返回的data字段为IP位置信息,如果要查寻当前客户端IP位置信息,需要组合使用。

2. Third-party personal open IP information attribution query API

https://api.vvhan.com/api/getIpInfo?ip=[IP地址串]

{
    
    
  "success": true,
  "ip": "47.98.234.90",
  "info": {
    
    
    "country": "中国",
    "prov": "浙江省",
    "city": "杭州市",
    "lsp": "电信",
    "postcode": "330100"
  }
}

Note: Do not fill in the IP address string, and the current IP information ownership details will be obtained by default.

3. Other APIs

https://ip.useragentinfo.com/json?ip=[IP地址串]

{
    
    
  "country": "美国",
  "short_name": "US",
  "province": "北卡罗来纳",
  "city": "梅登",
  "area": "",
  "isp": "Apple",
  "net": "",
  "ip": "17.36.12.79",
  "code": 200,
  "desc": "success"
}

Note: Do not fill in the IP address string, and the current IP information ownership details will be obtained by default.

Guess you like

Origin blog.csdn.net/qq_43762932/article/details/129408876