目前作一個項目,須要判斷是國內仍是國外的IP,具體要求爲接口穩定,速度快,免費,不異常
,因此我整理了優質的接口供你們篩選。php
IP歸屬地查詢APIjson
一,淘寶API接口
http://ip.taobao.com/service/getIpInfo.php?ip=[ip地址字串]
在ip
參數中添加你要查詢的ip
,數據報道查看爲json
格式。包括國家地區運營商等數據。api
{"code":0,"data":{"ip":"221.218.209.125","country":"中國","area":"","region":"北京","city":"北京","county":"XX","isp":"聯通","country_id":"CN","area_id":"","region_id":"110000","city_id":"110100","county_id":"xx","isp_id":"100026"}}
測評結果:ruby
查詢到: 110 未查詢到: 0 報錯: 890 執行時間 314.29S
二,IP-API接口
調用能夠http://ip-api.com/json/
接口查詢域名,默認爲當前請求的IP
。bash
# 國際化英文顯示 http://ip-api.com/json/ # 修改語言編碼 http://ip-api.com/json/?lang=zh-CN # 修改IP信息 http://ip-api.com/json/115.191.200.34?lang=zh-CN
數據報道查看爲json
格式。包括國家地區運營商等數據。jsp
{"as":"AS6106 University of California, Riverside","city":"里弗賽德","country":"美國","countryCode":"US","isp":"University of California, Riverside","lat":33.9473,"lon":-117.4008,"org":"University of California, Riverside","query":"169.235.24.133","region":"CA","regionName":"加利福尼亞州","status":"success","timezone":"America/Los_Angeles","zip":"92521"}
測評結果:ide
沒有測試完,應該是有調用量限制,不過一開始查詢比淘寶快。
三,搜狐IP地址查詢
http://pv.sohu.com/cityjson # 設置編碼 http://pv.sohu.com/cityjson?ie=utf-8
當前只能查到區域信息,數據劃分不是很明確:測試
var returnCitySN = {"cip": "221.218.209.125", "cid": "110108", "cname": "北京市海淀區"};
四,太平洋IP地址查詢
太平洋IP地址庫API接口爲:編碼
http://whois.pconline.com.cn/ipJson.jsp?ip=xxx.xxx.xxx.xxx&json=true
查詢到數據以下:spa
{"ip":"221.218.209.125","pro":"北京市","proCode":"110000","city":"北京市","cityCode":"110000","region":"海淀區","regionCode":"110108","addr":"北京市海淀區 聯通ADSL","regionNames":"","err":""}
太平洋IP查詢的更多接入方式查看http://whois.pconline.com.cn/
測試結果:
查詢到: 1000 未查詢到: 0 報錯: 0 執行時間 68.51S
調用了三個接口,淘寶那個接口好用,可是對查詢的頻率有限制,瑕疵有點大,特地增長後面的兩個接口,防止查詢屢次查詢不出來的結果。