我将使用可以返回JSON的Web服务(与jQuery一起使事情变得更简单)。以下是我可以找到的所有免费的 Activity IP查找服务以及它们返回的信息。如果您知道更多信息,请添加评论,我将更新此答案。
Abstract
尝试一下: https://ipgeolocation.abstractapi.com/v1/?api_key=<your_api_key>
$.getJSON('https://ipgeolocation.abstractapi.com/v1/?api_key=<your_api_key>', function(data) {
console.log(JSON.stringify(data, null, 2));
});
返回值:
{
"ip_address": "116.12.250.1",
"city": "Singapore (Queenstown Estate)",
"city_geoname_id": 1884386,
"region": null,
"region_iso_code": null,
"region_geoname_id": null,
"postal_code": null,
"country": "Singapore",
"country_code": "SG",
"country_geoname_id": 1880251,
"country_is_eu": false,
"continent": "Asia",
"continent_code": "AS",
"continent_geoname_id": 6255147,
"longitude": 103.807,
"latitude": 1.29199,
"timezone": {
"name": "Asia/Singapore",
"abbreviation": "+08",
"gmt_offset": 8,
"current_time": "22:33:13",
"is_dst": false
},
"flag": {
"emoji": "🇸🇬",
"unicode": "U+1F1F8 U+1F1EC",
"png": "https://static.abstractapi.com/country-flags/SG_flag.png",
"svg": "https://static.abstractapi.com/country-flags/SG_flag.svg"
},
"connection": {
"autonomous_system_number": 3758,
"autonomous_system_organization": "SingNet Pte Ltd",
"connection_type": "Corporate",
"isp_name": "SingNet Pte Ltd",
"organizaton_name": "Singapore Post LTD"
}
}
局限性:每月20,000个请求需要注册才能获取您的API key AstroIP.co 尝试一下: https://api.astroip.co/116.12.250.1/?api_key=<your_api_key>$.getJSON('https://api.astroip.co/116.12.250.1/?api_key=<your_api_key>', function(data) {
console.log(JSON.stringify(data, null, 2));
});
返回值:
{
"status-code": 200,
"geo": {
"is-metric": true,
"is-in-europe": false,
"longitude": 103.7601,
"latitude": 1.3125,
"country-geo-id": 1880251,
"zip-code": "12",
"city": "Singapore",
"region-code": null,
"region-name": null,
"continent-code": "AS",
"continent-name": "Asia",
"capital": "Singapur",
"country-name": "Singapore",
"country-iso-code": "SG"
},
"asn": {
"route": "116.12.240.0/20",
"name": "SINGNET",
"type": "business",
"domain": "singtel.com",
"organization": "SingNet",
"asn": "AS3758"
},
"currency": {
"native-name": "新加坡元",
"code": "SGD",
"name": "Singapore Dollar",
"symbol": "$"
},
"timezone": {
"is-daylight-saving": false,
"gmt-offset": 28800,
"date-time": "2020-11-12T15:28:45+08:00",
"microsoft-name": "Asia/Singapore",
"iana-name": "Asia/Singapore"
},
"security": {
"is-crawler": false,
"is-proxy": false,
"is-tor": false,
"tor-insights": null,
"proxy-insights": null,
"crawler-insights": null
},
"crypto": null,
"user-agent": null,
"error": null,
"hostname": "116.12.250.1",
"ip-type": "ipv4",
"ip": "116.12.250.1"
}
局限性:每月30,000个免费请求需要注册才能获取您的API key Cloudflare 尝试一下: https://www.cloudflare.com/cdn-cgi/trace// If your site is on Cloudflare, then you can use '/cdn-cgi/trace' instead
$.get('https://www.cloudflare.com/cdn-cgi/trace', function(data) {
console.log(data)
})
返回值:
fl=4f422
h=www.cloudflare.com
ip=54.193.27.106
ts=1575967108.245
visit_scheme=https
uag=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36 Hypothesis-Via
colo=SJC
http=http/1.1
loc=US
tls=TLSv1.3
sni=plaintext
warp=off
局限性:返回纯文本 DB-IP 尝试一下: http://api.db-ip.com/addrinfo?api_key=<your_api_key>&addr=<ip_address>返回值:
{
"address": "116.12.250.1",
"country": "SG",
"stateprov": "Central Singapore",
"city": "Singapore"
}
局限性:每天2,500个请求不支持JSONP回调需要IP地址参数需要电子邮件地址才能获取您的API key 带有免费计划的SSL(https)
Geobytes 尝试一下: http://gd.geobytes.com/GetCityDetails$.getJSON('http://gd.geobytes.com/GetCityDetails?callback=?', function(data) {
console.log(JSON.stringify(data, null, 2));
});
返回值:
{
"geobytesforwarderfor": "",
"geobytesremoteip": "116.12.250.1",
"geobytesipaddress": "116.12.250.1",
"geobytescertainty": "99",
"geobytesinternet": "SA",
"geobytescountry": "Saudi Arabia",
"geobytesregionlocationcode": "SASH",
"geobytesregion": "Ash Sharqiyah",
"geobytescode": "SH",
"geobyteslocationcode": "SASHJUBA",
"geobytescity": "Jubail",
"geobytescityid": "13793",
"geobytesfqcn": "Jubail, SH, Saudi Arabia",
"geobyteslatitude": "27.004999",
"geobyteslongitude": "49.660999",
"geobytescapital": "Riyadh ",
"geobytestimezone": "+03:00",
"geobytesnationalitysingular": "Saudi Arabian ",
"geobytespopulation": "22757092",
"geobytesnationalityplural": "Saudis",
"geobytesmapreference": "Middle East ",
"geobytescurrency": "Saudi Riyal",
"geobytescurrencycode": "SAR",
"geobytestitle": "Saudi Arabia"
}
局限性:每小时16,384个请求带有免费计划的SSL(https)
可以返回错误的位置(我在新加坡,而不是沙特阿拉伯) GeoIPLookup.io 尝试一下: https://json.geoiplookup.io/api$.getJSON('https://json.geoiplookup.io/api?callback=?', function(data) {
console.log(JSON.stringify(data, null, 2));
});
返回值:
{
"ip": "116.12.250.1",
"isp": "SGPOST",
"org": "Singapore Post Ltd",
"hostname": "116.12.250.1",
"longitude": "103.807",
"latitude": "1.29209",
"postal_code": "",
"city": "Singapore",
"country_code": "SG",
"country_name": "Singapore",
"continent_code": "AS",
"region": "Central Singapore",
"district": "",
"timezone_name": "Asia\/Singapore",
"connection_type": "",
"asn": "AS3758 SingNet",
"currency_code": "SGD",
"currency_name": "Singapore Dollar",
"success": true
}
局限性:每小时10,000个请求免费API仅允许非商业用途 geoPlugin 尝试一下: http://www.geoplugin.net/json.gp$.getJSON('http://www.geoplugin.net/json.gp?jsoncallback=?', function(data) {
console.log(JSON.stringify(data, null, 2));
});
返回值:
{
"geoplugin_request": "116.12.250.1",
"geoplugin_status": 200,
"geoplugin_credit": "Some of the returned data includes GeoLite data created by MaxMind, available from <a href=\\'http://www.maxmind.com\\'>http://www.maxmind.com</a>.",
"geoplugin_city": "Singapore",
"geoplugin_region": "Singapore (general)",
"geoplugin_areaCode": "0",
"geoplugin_dmaCode": "0",
"geoplugin_countryCode": "SG",
"geoplugin_countryName": "Singapore",
"geoplugin_continentCode": "AS",
"geoplugin_latitude": "1.2931",
"geoplugin_longitude": "103.855797",
"geoplugin_regionCode": "00",
"geoplugin_regionName": "Singapore (general)",
"geoplugin_currencyCode": "SGD",
"geoplugin_currencySymbol": "$",
"geoplugin_currencySymbol_UTF8": "$",
"geoplugin_currencyConverter": 1.4239
}
局限性:每分钟120个请求带有免费计划的SSL(https)
Hacker Target 尝试一下: https://api.hackertarget.com/geoip/?q=<ip_address>返回值:
IP Address: 116.12.250.1
Country: SG
State: N/A
City: Singapore
Latitude: 1.293100
Longitude: 103.855797
局限性:每天50个请求不支持JSONP回调需要IP地址参数返回纯文本 ipapi.co 尝试一下: https://ipapi.co/json/$.getJSON('https://ipapi.co/json/', function(data) {
console.log(JSON.stringify(data, null, 2));
});
返回值:
{
"ip": "116.12.250.1",
"city": "Singapore",
"region": "Central Singapore Community Development Council",
"country": "SG",
"country_name": "Singapore",
"postal": null,
"latitude": 1.2855,
"longitude": 103.8565,
"timezone": "Asia/Singapore"
}
局限性:每天1,000个请求需要SSL(https) IP-API.com 尝试一下: http://ip-api.com/json$.getJSON('http://ip-api.com/json?callback=?', function(data) {
console.log(JSON.stringify(data, null, 2));
});
返回值:
{
"as": "AS3758 SingNet",
"city": "Singapore",
"country": "Singapore",
"countryCode": "SG",
"isp": "SingNet Pte Ltd",
"lat": 1.2931,
"lon": 103.8558,
"org": "Singapore Telecommunications",
"query": "116.12.250.1",
"region": "01",
"regionName": "Central Singapore Community Development Council",
"status": "success",
"timezone": "Asia/Singapore",
"zip": ""
}
局限性:每分钟150个请求带有免费计划的SSL(https)
Ipdata.co 尝试一下: https://api.ipdata.co$.getJSON('https://api.ipdata.co', function(data) {
console.log(JSON.stringify(data, null, 2));
});
返回值:
{
"ip": "116.12.250.1",
"city": "Singapore",
"region": "Central Singapore Community Development Council",
"region_code": "01",
"country_name": "Singapore",
"country_code": "SG",
"continent_name": "Asia",
"continent_code": "AS",
"latitude": 1.2931,
"longitude": 103.8558,
"asn": "AS3758",
"organisation": "SingNet",
"postal": "",
"calling_code": "65",
"flag": "https://ipdata.co/flags/sg.png",
"emoji_flag": "\ud83c\uddf8\ud83c\uddec",
"emoji_unicode": "U+1F1F8 U+1F1EC",
"is_eu": false,
"languages": [
{
"name": "English",
"native": "English"
},
{
"name": "Malay",
"native": "Bahasa Melayu"
},
{
"name": "Tamil",
"native": "\u0ba4\u0bae\u0bbf\u0bb4\u0bcd"
},
{
"name": "Chinese",
"native": "\u4e2d\u6587"
}
],
"currency": {
"name": "Singapore Dollar",
"code": "SGD",
"symbol": "S$",
"native": "$",
"plural": "Singapore dollars"
},
"time_zone": {
"name": "Asia/Singapore",
"abbr": "+08",
"offset": "+0800",
"is_dst": false,
"current_time": "2018-05-09T12:28:49.183674+08:00"
},
"threat": {
"is_tor": false,
"is_proxy": false,
"is_anonymous": false,
"is_known_attacker": false,
"is_known_abuser": false,
"is_threat": false,
"is_bogon": false
}
}
局限性:每天1,500个请求需要电子邮件地址才能获取您的API key 需要SSL(https) IP Find 尝试一下: https://ipfind.co/me?auth=<your_api_key>$.getJSON('https://ipfind.co/me?auth=<your_api_key>', function(data) {
console.log(JSON.stringify(data, null, 2));
});
返回值:
{
"ip_address": "116.12.250.1",
"country": "Singapore",
"country_code": "SG",
"continent": "Asia",
"continent_code": "AS",
"city": "Singapore",
"county": null,
"region": "Central Singapore",
"region_code": "01",
"timezone": "Asia/Singapore",
"owner": null,
"longitude": 103.8565,
"latitude": 1.2855,
"currency": "SGD",
"languages": [
"cmn",
"en-SG",
"ms-SG",
"ta-SG",
"zh-SG"
]
}
局限性:每天300个请求需要注册才能获取您的API key ipgeolocation 尝试一下: https://api.ipgeolocation.io/ipgeo?apiKey=<your_api_key>$.getJSON('https://api.ipgeolocation.io/ipgeo?apiKey=<your_api_key>', function(data) {
console.log(JSON.stringify(data, null, 2));
});
返回值:
{
"ip": "116.12.250.1",
"continent_code": "AS",
"continent_name": "Asia",
"country_code2": "SG",
"country_code3": "SGP",
"country_name": "Singapore",
"country_capital": "Singapore",
"state_prov": "Central Singapore",
"district": "",
"city": "Singapore",
"zipcode": "",
"latitude": "1.29209",
"longitude": "103.807",
"is_eu": false,
"calling_code": "+65",
"country_tld": ".sg",
"languages": "cmn,en-SG,ms-SG,ta-SG,zh-SG",
"country_flag": "https://ipgeolocation.io/static/flags/sg_64.png",
"isp": "SGPOST",
"connection_type": "",
"organization": "Singapore Post Ltd",
"geoname_id": "1880252",
"currency": {
"name": "Dollar",
"code": "SGD"
},
"time_zone": {
"name": "Asia/Singapore",
"offset": 8,
"is_dst": false,
"current_time": "2018-06-12 09:06:49.028+0800"
}
}
局限性:每月50,000个请求需要注册才能获取您的API key ipify 尝试一下: https://api.ipify.org/?format=json$.getJSON('https://api.ipify.org?format=jsonp&callback=?', function(data) {
console.log(JSON.stringify(data, null, 2));
});
返回值:
{
"ip": "116.12.250.1"
}
局限性:无 IPInfoDB 尝试一下: https://api.ipinfodb.com/v3/ip-city/?key=<your_api_key>&format=json$.getJSON('https://api.ipinfodb.com/v3/ip-city/?key=<your_api_key>&format=json&callback=?', function(data) {
console.log(JSON.stringify(data, null, 2));
});
返回值:
{
"statusCode": "OK",
"statusMessage": "",
"ipAddress": "116.12.250.1",
"countryCode": "SG",
"countryName": "Singapore",
"regionName": "Singapore",
"cityName": "Singapore",
"zipCode": "048941",
"latitude": "1.28967",
"longitude": "103.85",
"timeZone": "+08:00"
}
局限性:每秒两个请求需要注册才能获取您的API key ipinfo.io 尝试一下: https://ipinfo.io/json$.getJSON('https://ipinfo.io/json', function(data) {
console.log(JSON.stringify(data, null, 2));
});
返回值:
{
"ip": "116.12.250.1",
"hostname": "No Hostname",
"city": "Singapore",
"region": "Central Singapore Community Development Council",
"country": "SG",
"loc": "1.2931,103.8558",
"org": "AS3758 SingNet"
}
局限性:每天1,000个请求 Ipregistry 尝试一下: https://api.ipregistry.co/?key=<your_api_key>$.getJSON('https://api.ipregistry.co/?key=<your_api_key>', function(data) {
console.log(JSON.stringify(data, null, 2));
});
返回值:
{
"ip" : "116.12.250.1",
"type" : "IPv4",
"hostname" : null,
"carrier" : {
"name" : null,
"mcc" : null,
"mnc" : null
},
"connection" : {
"asn" : 3758,
"domain" : "singnet.com.sg",
"organization" : "SingNet Pte Ltd",
"type" : "isp"
},
"currency" : {
"code" : "SGD",
"name" : "Singapore Dollar",
"plural" : "Singapore dollars",
"symbol" : "SGD",
"symbol_native" : "SGD",
"format" : {
"negative" : {
"prefix" : "-SGD",
"suffix" : ""
},
"positive" : {
"prefix" : "SGD",
"suffix" : ""
}
}
},
"location" : {
"continent" : {
"code" : "AS",
"name" : "Asia"
},
"country" : {
"area" : 692.0,
"borders" : [ ],
"calling_code" : "65",
"capital" : "Singapore",
"code" : "SG",
"name" : "Singapore",
"population" : 5638676,
"population_density" : 8148.38,
"flag" : {
"emoji" : "🇸🇬",
"emoji_unicode" : "U+1F1F8 U+1F1EC",
"emojitwo" : "https://cdn.ipregistry.co/flags/emojitwo/sg.svg",
"noto" : "https://cdn.ipregistry.co/flags/noto/sg.png",
"twemoji" : "https://cdn.ipregistry.co/flags/twemoji/sg.svg",
"wikimedia" : "https://cdn.ipregistry.co/flags/wikimedia/sg.svg"
},
"languages" : [ {
"code" : "cmn",
"name" : "cmn",
"native" : "cmn"
}, {
"code" : "en",
"name" : "English",
"native" : "English"
}, {
"code" : "ms",
"name" : "Malay",
"native" : "Melayu"
}, {
"code" : "ta",
"name" : "Tamil",
"native" : "தமிழ்"
}, {
"code" : "zh",
"name" : "Chinese",
"native" : "中文"
} ],
"tld" : ".sg"
},
"region" : {
"code" : null,
"name" : "Singapore"
},
"city" : "Singapore",
"postal" : "96534",
"latitude" : 1.28967,
"longitude" : 103.85007,
"language" : {
"code" : "cmn",
"name" : "cmn",
"native" : "cmn"
},
"in_eu" : false
},
"security" : {
"is_bogon" : false,
"is_cloud_provider" : false,
"is_tor" : false,
"is_tor_exit" : false,
"is_proxy" : false,
"is_anonymous" : false,
"is_abuser" : false,
"is_attacker" : false,
"is_threat" : false
},
"time_zone" : {
"id" : "Asia/Singapore",
"abbreviation" : "SGT",
"current_time" : "2019-09-29T23:13:32+08:00",
"name" : "Singapore Standard Time",
"offset" : 28800,
"in_daylight_saving" : false
}
}
局限性:免费计划包括100,000个请求需要注册才能获取您的API key ipstack(以前为freegeoip.net)
尝试一下: http://api.ipstack.com/<ip_address>?access_key=<your_api_key>$.getJSON('http://api.ipstack.com/<ip_address>?access_key=<your_api_key>', function(data) {
console.log(JSON.stringify(data, null, 2));
});
返回值:
{
"ip": "116.12.250.1",
"type": "ipv4",
"continent_code": "AS",
"continent_name": "Asia",
"country_code": "SG",
"country_name": "Singapore",
"region_code": "01",
"region_name": "Central Singapore Community Development Council",
"city": "Singapore",
"zip": null,
"latitude": 1.2931,
"longitude": 103.8558,
"location": {
"geoname_id": 1880252,
"capital": "Singapore",
"languages": [{
"code": "en",
"name": "English",
"native": "English"
},
{
"code": "ms",
"name": "Malay",
"native": "Bahasa Melayu"
},
{
"code": "ta",
"name": "Tamil",
"native": "\u0ba4\u0bae\u0bbf\u0bb4\u0bcd"
},
{
"code": "zh",
"name": "Chinese",
"native": "\u4e2d\u6587"
}],
"country_flag": "http:\/\/assets.ipstack.com\/flags\/sg.svg",
"country_flag_emoji": "\ud83c\uddf8\ud83c\uddec",
"country_flag_emoji_unicode": "U+1F1F8 U+1F1EC",
"calling_code": "65",
"is_eu": false
}
}
局限性:每月10,000个请求需要IP地址参数需要注册才能获取您的API key 带有免费计划的SSL(https)
jsonip.com 尝试一下: https://jsonip.com$.getJSON('https://jsonip.com/?callback=?', function(data) {
console.log(JSON.stringify(data, null, 2));
});
返回值:
{
"ip": "116.12.250.1",
"about": "https://jsonip.com/about",
"Pro!": "http://getjsonip.com",
"Get Notifications": "https://jsonip.com/notify"
}
局限性:响应包括加售 JSON Test 尝试一下: http://ip.jsontest.com/$.getJSON('http://ip.jsontest.com/?callback=?', function(data) {
console.log(JSON.stringify(data, null, 2));
});
返回值:
{
"ip": "116.12.250.1"
}
局限性:没有SSL(https)下降了很多(超出配额),所以我不会将其用于生产如果您拥有一个,则返回IPv6地址,而这可能不是您想要的 Nekudo 尝试一下: https://geoip.nekudo.com/api$.getJSON('https://geoip.nekudo.com/api', function(data) {
console.log(JSON.stringify(data, null, 2));
});
返回值:
{
"city": "Singapore",
"country": {
"name": "Singapore",
"code": "SG"
},
"location": {
"accuracy_radius": 50,
"latitude": 1.2855,
"longitude": 103.8565,
"time_zone": "Asia/Singapore"
},
"ip": "116.12.250.1"
}
局限性:使用EasyPrivacy列表被广告阻止者阻止
请记住,由于这些都是免费服务,因此您的里程数可能会超出配额和正常运行时间,并且谁知道何时/是否将它们离线(图表A:
Telize)。如果您需要更多功能(例如SSL支持),其中的大多数服务还提供付费层。
另外,正如skobaljic在以下评论中指出的那样,请求配额大部分是学术性的,因为这是在客户端发生的,并且大多数最终用户永远不会超过配额。
更新 2016/2/1:删除了Telize(不再提供免费计划) 2016年4月18日:删除了freegeoip.net(服务停止) 2016年4月26日:添加了DB-IP 2016年4月26日:添加了Hacker Target 7/6/2016:恢复了freegeoip.net 2016年6月6日:删除了ip-json.rhcloud.com(无效链接) 2016年12月21日:删除了Hacker Target(服务中断) 2017年2月10日:添加了Nekudo 2017年4月20日:添加了ipapi.co(感谢Ahmad Awais) 2017年4月24日:恢复的Hacker Target 2017年4月24日:已删除Snoopi.io(服务中断) 2017年7月16日:添加了IP Find(感谢JordanC) 2017年7月16日:更新了不支持SSL的免费计划的限制 2017年9月25日:添加了Stupid Web Tools(感谢Cœur) 2018年3月16日:添加了Ipdata.co(感谢Jonathan) 2018年4月14日:将freegeoip.net重命名为ipstack(感谢MA-Maddin) 2018年4月16日:添加了GeoIPLookup.io(感谢Rob Waa) 2018年6月11日:添加了ipgeolocation(感谢Ejaz Ahmed) 2019年7月31日:添加了Ipregistry(感谢Laurent) 2019年8月16日:添加了SmartIP.io(感谢kevinj) 2019年8月22日:已删除Stupid Web Tools(停止服务) 12/8/2019:更改了Smart IP月费限制 12/10/2019:添加了Cloudflare 1/9/2020:删除了SmartIP.io(服务停止) 2020年11月6日:添加了Abstract 2020年11月13日:添加了AstroIP.co