How to get client's IP address using JavaScript?

 Admin   
706 View    Feb 7 2020 4:47PM

ipapi.co

 

Try it: https://ipapi.co/json/

 

$.getJSON('https://ipapi.co/json/', function(data) {

  console.log(JSON.stringify(data, null, 2));

});

 

Returns:

{

  "ip": "XXX.XX.XXX.X",

  "city": "Singapore",

  "region": "IND",

  "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)