For one of my project I needed IP geolocation database. While surfing I came to realize that there is a very good database available at iplocationtools.com. This website also provides XML API for this. This API can be accessed found at : IP Location API. However, for this particular project a needed some javascript API. My bad luck I couldn’t find one. So, I myself made that API (using iplocation database), Hope it will help you as well.
Update
The original source is also providing the same service in JSON. So I am shutting down my API and would request you to use the API provided by the IPLocationTools.com
IPlocationTools.com is now IP2Location.com, and they doesn’t provide APIs anymore. As the API provided by me were based on the IPLocationTools.com hence we have also stopped those APIs.
You can see http://www.ip2location.com/developers.aspx to see what are available options.
Moreover you can also see the free stable options available by Google at:
- With Google Gears : http://code.google.com/apis/gears/api_geolocation.html (it provides very accurate results, but requires Gears to be installed on client computer)
- Javascript : http://code.google.com/apis/ajax/documentation/#ClientLocation
Sorry Guys

Should have used YAHOO pipes for the conversion … would have taken the stress off ur server…
Here is the pipe….
http://pipes.yahoo.com/pipes/pipe.info?_id=pIRFfMQl3hGxAadF3nBDOQ
I just analysed your pipe and it seems it is taking data from iplocationtools.com, which is great. But somehow it is not returning my ip location
where as Nitin’s server does. Well, I don’t know what might be a problem here
PS. For jQuery adicts, here is jQuery geolocation script.
Twitter @jqueryHowto
Very usefull post.
I just checked Parashuman’s pipe and it is correctly retrieving the data from iplocationtools.com however, since the returned XML has no title nor description attributes Yahoo Pipes is unable to show the results. I have cloned the pipe and made the necesary changes. Here is the pipe.
http://pipes.yahoo.com/pipes/pipe.info?_id=20bb460bba7290ff75bf05cb30840697
I’m sorry, I should have written Parashuram instead of Parashuman.
If you’re going to use Google Maps. Why don’t you use the built in IP geolocation that comes with Google’s API?
Wow, this is really nice! Very easy to use.
Good job!
JSON requires object keys and string values to be enclosed in double quotes, intead of single quotes. As far as Javascript is concerned, the result is still a valid object, by it can break other clients using strict JSON parsers.
That’s pretty cool. Just wondering, why didn’t you use AJAX (JSON w/ callback) with a library like jQuery?
Here is a code and tutorial on how to use geolocation service with jQuery.
Hope others also will find it useful.
@jqueryHowto
Will add this soon on iplocationtools.com.
Thanks
Marc
Parashuram, thanks for telling me about Yahoo Pipes. Frankly speaking i didn’t knew about it.
Tim : I didn’t know that such a functionality exists in GOOGLE Maps. It would be helpful if you could point us to that.
Thanks Eric for pointing out wrong JSON structure.
Hao Chen i did it to keep is simple (KISS).
Marc, We would very much appreciate it.
[...] IP Address Geolocation Javascript API : JSON [...]
[...] Geolocalización de IP’s con JSON y Javascript. [...]
Very useful, thanks mate!
[...] IP Address Geolocation API е много полезно API Ñ Ñ‡Ð¸Ñто помощ може да откривате [...]
Great article and thanks for sharing this free service of yours. Inspired by your post here is an implementation of this geolocation identifiers service in jQuery.
The article desicribes the service and shows how to work with in jQuery.
wow very good idea
[...] IP Address Geolocation Javascript API : JSON | The Code Dreamer (tags: javascript ip api geolocation geocoding json Programming development maps location tools) [...]
Nice work
[...] IP Address Geolocation Javascript API : JSON [...]
[...] IP Address Geolocation Javascript API : JSON Click here to go to this script [...]
man.. this is really cool.
this is what i’ve been looking for. thanks!
Good work dude!
very good idea
wood pavilion
I found a new site to check out IP Address details through
http://www.ipaddressgeolocation.com
The google API is here: http://code.google.com/apis/ajax/documentation/#ClientLocation
Not working for me..
very very good!
Friends , Good that I found this blog. I am using geoplugin get my current location . Copy the following PHP code to server and acess it you will get the current location . But again this is not working in India . I tried for USA,India,Singapore and Australia .It worked for all countries except for India
. Are yahoo pipes are working for India also to get the current location of the person . If So can any body please provide me a snippet of PHP code that gets me Country,State and City ( for India too) . Thanks for your help.
Regards
Kiran
var_export(unserialize(file_get_contents(‘http://www.geoplugin.net/php.gp?ip=’.$_SERVER['REMOTE_ADDR'])));
This may help you:
http://ipinfodb.com/ip_location_api.php
They provide both xml and json apis
very nice cod. Thanks.
Thanks Stephen , That really helped me a lot
useful code… thanks
Geolocalización de IP’s con JSON y Javascript
Thanks for text. very good
Одни англичане.ICQ:414293541
Thanks for the feedback..!!
Thanks for the feedback..!!
I made a free service dedicated to this purpose: http://my-ip.cc/
Its API provides a JSONP version so the actual geolocation of your visitors can be available to your JavaScript code without even a roundtrip to your server.
Currently, it’s using http://hostip.info/ database for IP Geolocation, which is free and quite accurate as anyone can contribute to it, but it might be a good idea to integrate the ip2location service you’re mentionning too…
Thanks for sharing this !
Actually the address of this service is now http://what-ip.heroku.com/ and it will be open-sourced soon on GitHub.
We are using http://www.IPAddressLabs.com and so far we are very happy. Very accurate, REALLY FAST, and so far (as far as we know) it is verey reliable. No failures, or at least we haven’t detected any in our logs.
ugg boots, drugs whatever send me i order all – ok swell ? here i my adress facts
htpdvn@yahoo.com
I am currently using the API from http://www.ipgp.net/ip-address-geolocation-api/ on all my websites. I checked several systems and it is the most accurate.
http://www.IPAddressLabs.com now has a FREE edition, that tells you the continent and the country.
I am sure this article has touched all the internet visitors, its really really fastidious piece
of writing on building up new webpage.
また、優れた ケア のため ft これらによって撮影 履物 を正当化する 拍手します だから、は確かに 何か を 誰も で、家族。 Ugg のブーツをしに行ったから 要件 に 現代 ブート 周り は 非常に長い 期間 時間の。 あなたはプルに喜んでなりますあなた つま先 ブーツから。