Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I want to get zipcode of the particular ip address.
Already search enough web for this.
What I found is APIs which gives country from IP and there are some APIs for same purpose however they are not free.
If anyone have implemented something like this or any free APIs are there then it will be very useful.

Note : This is applicable only for US based IPs.
As it is going to be used in US only.

Thanks.
Posted
Updated 15-Dec-10 1:30am
v2
Comments
OriginalGriff 15-Dec-10 8:30am    
Answer updated

1 solution

You can't do it.

Remember, the IP is assigned by the ISP, and in most cases is not fixed - it is a dynamic IP address. What this means is that the IP address "78.145.xxx.xxx" is currently assigned to me, but if I disconnect my modem, and reconnect it could be assigned to someone 200 miles away.

In order to get the zip/post code from the IP, the ISP would have to translate it via their customer database. This isn't going to happen, without a court order - that kind of information is commercially confidential (it's their customer list!) and they won't hand it over in case you target their customers with cheaper offers.

In theory, you can get the city, but in practice, you will get A city - it could be hundreds of miles or more from the physical location of the PC using the IP address. And that's ignoring proxies...


"Thanks Griff,
I have thought same - "Dynamic IP"
That cleared the Vision now...
However I have couple of doubts, would you please look in the cases I have explained below.

In below case we are not considering customers privacy as you have explained, Then
ok...
1.
ISP have assigned dynamic ip temporarily to a user for a some amount of time then that IP would hold some location(temporaritly)!! And that location would be the related for that Address(Physical) for sometime only.
So for that particular amount of time atleast can we have the Zipcode of that IP address??

2.
Atleast can we have their City information if the IP is dynamic?

Thanks - Gandalf - The White 14 mins ago"



1) No, you can't - the ISP is the ONLY person who has that, and they will NOT give it to you until they are legally forced to do so. In some countries it is illegal for them to give you that information! (Data protection / privacy legislation)

2) You can get the City information, but is won't necessarily be accurate. For example, my City comes back as Berlin, Germany - I am in Wales, and hundreds of miles away (it would take about 24~36 hours to drive to Berlin) For what it's worth: hostip.info[^] have an API and examples.



"Gutan Tag Griff,

Now it gets clear completely, as ISPs are authorities those won't allow to get leak their customer information in their code of conduct under privacy legislation. So true...

So the API that you have mentioned is(hosip.info) to get city information from IP is Free?(as right now I can not open the link(blocked by firewall)). If it is free then It might solve my purpose upto some extent. Though its not accurate but it will have something show atleast.

Vielen Dank fur eure Hilfe
Permalink | Bookmark | Improve Answer |
Posted 1 hr ago
Gandalf - The White2.1K"


Yes, it is a community based project, so there is no charge.

By the way, don't use the "Add Answer" to reply - use the "Add Comment"
below the answer instead. That way, I get an email. If you use "Add
answer" then you are the only person who could get an email...
 
Share this answer
 
v3
Comments
Gandalf_TheWhite 15-Dec-10 8:09am    
Thanks Griff,
I have thought same - "Dynamic IP"
That cleared the Vision now...
However I have couple of doubts, would you please look in the cases I have explained below.

In below case we are not considering customers privacy as you have explained, Then
ok...
1.
ISP have assigned dynamic ip temporarily to a user for a some amount of time then that IP would hold some location(temporaritly)!! And that location would be the related for that Address(Physical) for sometime only.
So for that particular amount of time atleast can we have the Zipcode of that IP address??

2.
Atleast can we have their City information if the IP is dynamic?

Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900