快速接入指南

使用快速接入指南在几秒钟内发出 API 请求。

代码示例

跳至编程语言的代码示例,例如 JavaScript 和 PHP (CURL) 。

查看代码示例

API接口

INIP 提供了易于使用的 API 接口,允许用户查看与 IPv4 和 IPv6 地址关联的各种信息。对于处理的每个 IP 地址,API 返回超过 10 个独特的数据信息,例如位置数据、ISP 信息、时区、IP类型和安全评估数据。

该 API 基于 REST,使用简单的 HTTP GET URL 发出查找请求,并在几毫秒内以轻量级 JSON 格式返回结果。

此 API 文档将详细概述 API 的访问和功能。在最底部您将找到不同编程语言的代码示例。

API响应

API 请求成功后,API 将返回 10 多个包含结果数据的唯一响应对象。API 响应可以 JSON 格式返回,包括如下:位置数据、ISP 信息、时区、IP类型和安全评估数据。

API 响应示例:

{ "ip": "89.187.160.76", "organization": "Datacamp Limited", "asn": 60068, "network": "89.187.160.0/23", "country_cn": "日本", "country": "Japan", "country_code": "JP", "city_cn": "东京", "city": "Tokyo", "continent_cn": "亚洲", "continent": "Asia", "continent_code": "AS", "postal": "102-0082", "latitude": 35.6893, "longitude": -139.6899, "timezone": "Asia/Tokyo", "metro_code": null, "region_code": "13", "region_cn": "", "region": "Tokyo", "ip_type": "RES" }
JSON

请注意: 上面的结果中仅为示例数据.

API 错误代码

如果您的 API 请求因任何原因失败,API 将返回一条 JSON 错误消息,详细说明所发生错误的相关信息。


常见 API 错误:

编码 类型 信息
404 404_not_found 用户请求了不存在的资源。
500 500_sys_error 服务器错误。

API 功能

查询当前IP信息

请求URL:http://inip.in/ip.json


API 响应示例:

{ "ip": "89.187.160.76", # 当前IP地址 "organization": "Datacamp Limited", # IP所属组织 "asn": 60068, # ASN "network": "89.187.160.0/23", # 网络 "country_cn": "日本", # 国家 "country": "Japan", # 国家英文 "country_code": "JP", # 国家代码 "city_cn": "东京", # 城市 "city": "Tokyo", # 城市英文 "continent_cn": "亚洲", # 州 "continent": "Asia", # 州英文 "continent_code": "AS", # 州代码 "postal": "102-0082", # 邮政编码 "latitude": 35.6893, # 纬度 "longitude": -139.6899, # 经度 "timezone": "Asia/Tokyo", # 时区 "metro_code": null, # 地铁编码 "region_code": "13", # 省份编码 "region_cn": "", # 省份 "region": "Tokyo", # 省份英文 "ip_type": "RES" # IP类型, RES:住宅, DC:机房 }
JSON

查询指定IP信息

请求URL:http://inip.in/search_ip?ip=89.187.160.76


API 响应示例:

{ "code": 0, "data": { "asn": 60068, # ASN "city": "Tokyo", # 城市英文 "city_cn": "东京", # 城市 "continent": "Asia", # 州英文 "continent_cn": "亚洲", # 州 "continent_code": "AS", # 州代码 "country": "Japan", # 国家英文 "country_cn": "日本", # 国家 "country_code": "JP", # 国家代码 "ip": "89.187.160.76", # IP地址 "ip_type": "RES", # IP类型, RES:住宅, DC:机房 "latitude": 35.6893, # 纬度 "longitude": -139.6899, # 经度 "metro_code": null, # 地铁编码 "network": "89.187.160.0/23", # 网络 "organization": "Datacamp Limited", # IP所属组织 "postal": "102-0082", # 邮政编码 "region": "Tokyo", # 省份英文 "region_cn": "", # 省份 "region_code": "13", # 省份编码 "timezone": "Asia/Tokyo" #时区 }, "msg": "success" }
JSON

代码示例

PHP (CURL)

通过 PHP 进行标准查找

// 指定IP地址
$ip = '89.187.160.76';

// 初始化 CURL:
$ch = curl_init('http://inip.in/search_ip?ip='.$ip.');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// 存储数据:
$json = curl_exec($ch);
curl_close($ch);

// 解码 JSON 响应:
$api_result = json_decode($json, true);

// 输出 "country_code" 对象
echo $api_result['data']['country_code'];

JavaScript

通过 JavaScript 进行标准查找

// 指定IP地址
var ip = '89.187.160.76'

// 通过 jQuery.ajax 获取 API 结果
$.ajax({
    url: 'http://inip.in/search_ip?ip=' + ip ,
    dataType: 'jsonp',
    success: function(json) {

        // 输出 "country_code" 对象
        alert(json.data.country_code);
        
    }
});