How to Get Client's Ip Address Using Javascript?

How to Get Client's Ip Address Using Javascript?

I need to somehow retrieve the client's IP address using JavaScript; no server side code, not even SSI.

However, I'm not against using a free 3rd party script/service.

0

48 Answers

I would use a web service that can return JSON (along with jQuery to make things simpler). Below are all the active free IP lookup services I could find and the information they return. If you know of others, then please add a comment and I'll update this answer.


Abstract

let apiKey = '1be9a6884abd4c3ea143b59ca317c6b2';
$.getJSON(' + apiKey, function(data) {
  console.log(JSON.stringify(data, null, 2));
});
<script src=""></script>

Limitations:

  • 10,000 requests per month
  • Requires registration to get your API key

Alexander Ross
Author

Alexander Ross

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.