IP Address location

Free IP geolocation webservice

This is a free for finding IP address geo location. The database is very accurate and contains the following items as out:

  • Country (code/name)
  • Region (code/name)
  • City
  • Zip Code
  • Latitude
  • Longitude

Data is served in different formats, such as CSV, XML or JSON.

Currently supported formats are:

 

  • CSV: http://freegeoip.appspot.com/csv/[ip-address]
  • XML: http://freegeoip.appspot.com/xml/[ip-address]
  • JSON: http://freegeoip.appspot.com/json/[ip-address]

Requests are simple REST URLs, allowing anyone to query from any language.
for example: in Asp.Net

XmlTextReader reader = new XmlTextReader(“http://freegeoip.appspot.com/xml/” +Request.ServerVariables[“REMOTE_ADDR”]);
reader.WhitespaceHandling = WhitespaceHandling.Significant;
string state = “”;
string city = “”;
while(reader.Read())
{
if (reader.Name.ToString() == “RegionName”)
{
state = reader.ReadString().ToString();
}
if (reader.Name.ToString() == “City”)
{
city = reader.ReadString().ToString();
}
}
Data formats
CSV

The Comma Separated Values format will always return 10 columns in a single line, like this:

status,ip,countrycode,countryname,regioncode, regionname,city,zipcode,latitude,longitude

The data in the first two columns will always be present. Status can be either true or false, and must be used to determine the success or failure of the query.

XML

The Extensible Markup Language format will always return the same document structure, with a Status node containing either true or false, used to determine the success or failure of a query.
Here is an example of the reply:

<?xml version=”1.0″ encoding=”UTF-8″?>
<Response>
<Status>true</Status>
<Ip>x.x.x.x</Ip>
<CountryCode>IN</CountryCode>
<CountryName>India</CountryName>
<RegionCode>TN</RegionCode>
<RegionName>Tamil Nadu</RegionName>
<City>Chennai</City>
<ZipCode>xxxxx</ZipCode>
<Latitude>-xx.xxxx</Latitude>
<Longitude>-xx.xxxx</Longitude>
</Response>
JSON

The JavaScript Object Notation is also available, and is the preferred method for retrieving the results.
The status key can be either true or false and is used to determine the success or failure of a query:

{“status”:true,”ip”:”x.x.x.x”,
“countrycode”:”IN”,”countryname”:”India”,
“regioncode”:”TN”,”regionname”:”Tamil Nadu”,
“city”:”Chennai”,”zipcode”:”xxxx”,
“latitude”:-xx.xxxx,”longitude”:-xx.xxxx}

*Note:-Latitude,Longitude are very useful for Map service.

Thank you,
Naga Harish.
Follow me on Twitter Naga harish

One thought on “IP Address location

  1. Sometimes it is showing this message.
    “This Google App Engine application is temporarily over its serving quota. Please try again later.”
    I hope, Freegeoip is developed by Google.

Leave a Reply