views:

2117

answers:

5

I am looking for advice for open API or 3d party products which will help to convert an IP address to a zip code and city, to make geo-specific web site content.

+4  A: 

IP2Location

http://www.ip2location.com/developers.aspx

BobbyShaftoe
This is probably what the OP is looking for, just be aware that the tech behind this type of service is not 100% reliable. You get the location of a client's ISP, not the client itself.
Bill the Lizard
For instance, our ISP is in Queensland. But we're in Western Australia, about 4000 kilometres away.
boost
Right, it depends on your purpose. Sometimes, its good enough, say for targeted advertisements or whatever.
BobbyShaftoe
+4  A: 

What I use is ip2nation: http://www.ip2nation.com

It is a completely free MySQL database of IP to country mappings. They include a few sample PHP scripts at their site.

I use it on my WordPress blog along with Ozh's free IP to Nation WordPress Plugin

Even if you are not using WordPress, download the plugin as it will give you a good set of PHP code to access the database with. He even has a nice set of tiny country flags that you can display next to, or instead of the country name, which is what I do to automatically show flags next my blog's commenter's names.

Really, you don't need an API for this. All you need is the database and an ability to write the PHP and SQL code to access it.

I wouldn't recommend ip2location for casual use. They charge a lot for their databases, and their databases are very large, and have more detail than most people need.

But ip2nation only goes to the Country level. If you do need Cities and Zipcodes (despite the fact that they can be wrong as other answers/comments have stated), then in addition to ip2location, you can try GeoBytes. They have components specifically suited for geo-specific web site content, such as GeoSelect: http://www.geobytes.com/GeoSelect.htm

Also search for "ip to zipcode" on Google.

lkessler
This is good if all you are looking for is country data, otherwise I would use 1p2location.
Unkwntech
+5  A: 

How do you map IP to location and zipcode?

badly.

I actually have two internet connections, DSL and cable model, and as a result depending on which one I use, I'm either in Broomfield or Wheat Ridge CO. When I'm at the office, a couple thousand yards from here, I'm in Menlo Park CA.

Charlie Martin
I agree - geolocating IPs can be questionable. Depending on when I test my home IP (DHCP from ISP), it might put me close to home or 2000 miles away. And from the office, my IP appears to be in a different country because of the corporate firewall.
Technical Bard
+1  A: 

Something to take into consideration is that visitors might freak out a bit if some web form would pre-fill their zip code. That might seem like too invasive, and people less technically knowledgeable might think they are spied upon. This, in turn, would lead to negative associations with your website, less visitors, and bad karma for you :)

OTOH, It didn't become apparent to me how you would've used the zipcode info, so, season with salt to taste

Henrik Paul
so maybe just tell them if they put in a zipcode that doesn't match their geolocated location? so maybe 'Before clicking continue do you see any of the following animals outside your window: kangaroos, wallabees or koalas'
Simon_Weaver
A: 

Best (meaning easy to integrate and free) way I've found is available here. The service is completely free, doesn't require any local installations and doesn't force you to put banners on your site (as opposed to IP2Location). The only restriction they have, the query limit, is very reasonable: you can fire a query every 2 seconds, and even if you make more frequent queries, you'll get the results just a bit slower. Enjoy!

András Szepesházi