Skip to content

Instantly share code, notes, and snippets.

@santanup789
Last active February 3, 2021 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save santanup789/16e8671fe36ecf84ad3cd168596bec21 to your computer and use it in GitHub Desktop.
Save santanup789/16e8671fe36ecf84ad3cd168596bec21 to your computer and use it in GitHub Desktop.
Get data from IP for website
<div id='long'></div>
<div id='long'></div>
<pre id="response"></pre>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$.get("https://api.ipdata.co/?api-key=test", function (response) {
$("#response").html(JSON.stringify(response, null, 4));
$("#long").html(response.latitude + ", " + response.longitude);
$("#long").html(response.city + ", " + response.longitude);
}, "jsonp");
</script>
//Response will be like this
{
"ip": "47.15.28.150",
"is_eu": false,
"city": "Kolkata",
"region": "West Bengal",
"region_code": "WB",
"country_name": "India",
"country_code": "IN",
"continent_name": "Asia",
"continent_code": "AS",
"latitude": 22.5602,
"longitude": 88.3698,
"postal": "700063",
"calling_code": "91",
"flag": "https://ipdata.co/flags/in.png",
"emoji_flag": "🇮🇳",
"emoji_unicode": "U+1F1EE U+1F1F3",
"asn": {
"asn": "AS55836",
"name": "Reliance Jio Infocomm Limited",
"domain": "jio.com",
"route": "47.15.0.0/18",
"type": "isp"
},
"carrier": {
"name": "Reliance",
"mcc": "404",
"mnc": "09"
},
"languages": [
{
"name": "Hindi",
"native": "हिन्दी"
},
{
"name": "English",
"native": "English"
}
],
"currency": {
"name": "Indian Rupee",
"code": "INR",
"symbol": "Rs",
"native": "টকা",
"plural": "Indian rupees"
},
"time_zone": {
"name": "Asia/Kolkata",
"abbr": "IST",
"offset": "+0530",
"is_dst": false,
"current_time": "2021-02-03T20:03:36.322896+05:30"
},
"threat": {
"is_tor": false,
"is_proxy": false,
"is_anonymous": false,
"is_known_attacker": false,
"is_known_abuser": false,
"is_threat": false,
"is_bogon": false
},
"count": "1522"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment