博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
JavaScript 获得客户端IP
阅读量:6332 次
发布时间:2019-06-22

本文共 9748 字,大约阅读时间需要 32 分钟。

Below are all the free active IP lookup services I could find and the information they return. If you know of any more, then please add a comment and I'll update this answer.


Try it: 

Returns:

{
"address": "116.12.250.1", "country": "SG", "stateprov": "Central Singapore", "city": "Singapore" }

Limitations:

  • 2,500 requests per day
  • Doesn't support JSONP callbacks
  • Requires IP address parameter
  • Requires email address to get your API key
  • No SSL (https) with free plan

Try it: 

$.getJSON('http://gd.geobytes.com/GetCityDetails?callback=?', function(data) { console.log(JSON.stringify(data, null, 2)); });

Returns:

{
"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" }

Limitations:

  • 16,384 requests per hour
  • No SSL (https) with free plan
  • Can return the wrong location (I'm in Singapore, not Saudi Arabia)

Try it: 

$.getJSON('https://json.geoiplookup.io/api?callback=?', function(data) { console.log(JSON.stringify(data, null, 2)); });

Returns:

{
"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 }

Limitations:

  • Unknown

Try it: 

$.getJSON('http://www.geoplugin.net/json.gp?jsoncallback=?', function(data) { console.log(JSON.stringify(data, null, 2)); });

Returns:

{
"geoplugin_request": "116.12.250.1", "geoplugin_status": 200, "geoplugin_credit": "Some of the returned data includes GeoLite data created by MaxMind, available from http://www.maxmind.com.", "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 }

Limitations:

  • 120 requests per minute
  • No SSL (https) with free plan

Try it: 

Returns:

IP Address: 116.12.250.1Country: SGState: N/ACity: SingaporeLatitude: 1.293100Longitude: 103.855797

Limitations:

  • 50 requests per day
  • Doesn't support JSONP callbacks
  • Requires IP address parameter
  • Returns plain text

Try it: 

$.getJSON('https://ipapi.co/json/', function(data) { console.log(JSON.stringify(data, null, 2)); });

Returns:

{
"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" }

Limitations:

  • 1,000 requests per day
  • Requires SSL (https)

Try it: 

$.getJSON('http://ip-api.com/json?callback=?', function(data) { console.log(JSON.stringify(data, null, 2)); });

Returns:

{
"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": "" }

Limitations:

  • 150 requests per minute
  • No SSL (https) with free plan

Try it: 

$.getJSON('https://api.ipdata.co', function(data) { console.log(JSON.stringify(data, null, 2)); });

Returns:

{
"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.2854999999999999, "longitude": 103.8565, "asn": "AS3758", "organisation": "SingNet", "postal": "", "currency": "SGD", "currency_symbol": "$", "calling_code": "65", "flag": "https://ipdata.co/flags/sg.png", "emoji_flag": "??", "time_zone": "Asia/Singapore", "is_eu": false, "suspicious_factors": { "is_tor": false } }

Limitations:

  • 1,500 requests per day
  • Requires SSL (https)

Try it: 

$.getJSON('https://ipfind.co/me?auth=
', function(data) { console.log(JSON.stringify(data, null, 2)); });

Returns:

{
"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" ] }

Limitations:

  • 300 requests per day
  • Requires registration to get your API key

Try it: 

$.getJSON('https://api.ipify.org?format=jsonp&callback=?', function(data) { console.log(JSON.stringify(data, null, 2)); });

Returns:

{
"ip": "116.12.250.1" }

Limitations:

  • None

Try it: 

$.getJSON('https://api.ipinfodb.com/v3/ip-city/?key=
&format=json&callback=?', function(data) { console.log(JSON.stringify(data, null, 2)); });

Returns:

{
"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" }

Limitations:

  • Two requests per second
  • Requires registration to get your API key

Try it: 

$.getJSON('https://ipinfo.io/json', function(data) { console.log(JSON.stringify(data, null, 2)); });

Returns:

{
"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" }

Limitations:

  • 1,000 requests per day

 (formerly freegeoip.net)

Try it: 

$.getJSON('http://api.ipstack.com/
?access_key=
', function(data) { console.log(JSON.stringify(data, null, 2)); });

Returns:

{
"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 } }

Limitations:

  • 10,000 requests per month
  • Requires IP address parameter
  • Requires registration to get your API key
  • No SSL (https) with free plan

Try it: 

$.getJSON('https://jsonip.com/?callback=?', function(data) { console.log(JSON.stringify(data, null, 2)); });

Returns:

{
"ip": "116.12.250.1", "about": "/about", "Pro!": "http://getjsonip.com", "reject-fascism": "Liberal America will prevail" }

Limitations:

  • Response includes upsell and politics

Try it: 

$.getJSON('http://ip.jsontest.com/?callback=?', function(data) { console.log(JSON.stringify(data, null, 2)); });

Returns:

{
"ip": "116.12.250.1" }

Limitations:

  • No SSL (https)
  • Goes down a lot (over quota), so I wouldn't use it for production
  • Returns IPv6 address if you have one, which may not be what you want

Try it: 

$.getJSON('https://geoip.nekudo.com/api/
', function(data) { console.log(JSON.stringify(data, null, 2)); });

Returns:

{
"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" }

Limitations:

  • Requires IP address parameter
  • Blocked by ad blockers using EasyPrivacy list

Try it: 

$.getJSON('http://www.stupidwebtools.com/api/my_ip.json', function(data) { console.log(JSON.stringify(data, null, 2)); });

Returns:

{
"my_ip": { "ip": "116.12.250.1", "others": [] } }

Limitations:

  • No SSL (https)

Keep in mind that since these are all free services, your mileage may vary in terms of exceeding quota and uptime, and who knows when/if they will be taken offline down the road (exhibit A: ). Most of these services also offer a paid tier in case you want more features like SSL support.

Also, as skobaljic noted in the comments below, the request quotas are mostly academic since this is happening client-side and most end users will never exceed the quota.

转载于:https://www.cnblogs.com/JasonBie/p/8926986.html

你可能感兴趣的文章
【每天一个Linux命令】12. Linux中which命令的用法
查看>>
软件接口数据一致性机制
查看>>
微服务架构介绍和RPC框架对比
查看>>
Debian下使用OpenLDAP 管理端
查看>>
泛型排序器TComparer
查看>>
9个offer,12家公司,35场面试,从微软到谷歌,应届计算机毕业生的2012求职之路...
查看>>
创建符合标准的、有语意的HTML页面——ASP.NET 2.0 CSS Friendly Control Adapters 1.0发布...
查看>>
Adobe驳斥Flash过度耗电论 称HTML5更耗电
查看>>
No!No!No! It's not fashion!
查看>>
艰困之道中学到的经验教训
查看>>
互联网生态建设落地五大挑战——保险科技生态建设 ...
查看>>
进行短视频app开发工作时,可以加入它来保护青少年 ...
查看>>
25G DAC无源高速线缆和25G光模块之间的区别
查看>>
乐乐茶完成近2亿元Pre-A轮融资,祥峰投资领投
查看>>
clickhouse修改时区
查看>>
CSS_定位
查看>>
第二十四章:页面导航(六)
查看>>
百度、长沙加码自动驾驶,湖南阿波罗智行科技公司成立 ...
查看>>
10 个 Linux 中方便的 Bash 别名
查看>>
[Server] 服务器配置SSH登录邮件通知
查看>>