跳至主要內容

IP 服务

小于 1 分钟

IP 服务

POST 获取 IP 地理位置信息

Request Method

⚠️ 只支持 post 请求

Request Url

POST https://api.xygeng.cn/openapi/ip/getInfo

Body Parameters

{
  "ip": "string"
}

Request Code

// js演示
var axios = require('axios');
var data = JSON.stringify({
  ip: '116.119.168.152'
});

// 注意只支持post请求
var config = {
  method: 'post',
  url: 'https://api.xygeng.cn/openapi/ip/getInfo',
  headers: {
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36',
    'Content-Type': 'application/json',
    Accept: '*/*',
    Connection: 'keep-alive'
  },
  data: data
};

axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.log(error);
  });
# curl演示 只支持post请求
curl --location --request POST 'https://api.xygeng.cn/openapi/ip/getInfo' \
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36' \
--header 'Content-Type: application/json' \
--header 'Accept: */*' \
--header 'Connection: keep-alive' \
--data-raw '{
    "ip": "116.119.168.152"
}'

Response Examples

成功

{
  "code": 200,
  "data": {
    "country": "印度",
    "city": "",
    "province": "德里国家首都辖区",
    "isp": "印度电信"
  },
  "error": null,
  "updateTime": 1702634088798
}

失败

{
  "code": "IP_PARAM_FAILED",
  "data": null,
  "error": null,
  "userMsg": "参数不对",
  "updateTime": 1702634033023
}
上次编辑于:
贡献者: xygengcn