Click here to Skip to main content
11,639,861 members (62,627 online)
Click here to Skip to main content

Tagged as

LocatorHQ - Get Country/Region/City From IP Address

, 14 Jan 2014 CPOL 5.9K 8
Rate this:
Please Sign up or sign in to vote.
Easily get Country, Region and Citry of web visitors from their IP address.

Register FREE Username and API key at http://www.locatorhq.com[^]

Then, get the data by accessing: 

http://api.locatorhq.com/?user=<username>&key=<apikey>&ip=<ipaddress>  

Example:

http://api.locatorhq.com/?user=john3041&key=27364b3d6060c9e0738754c9be60908ab00ac7&ip=64.233.191.255 

Data return in this format:

<countryCode>,<countryName>,<region>,<city>,<latitude>,<longitude>

Example:

US,United States,California,Mountain View,34.305,-86.2981,64.233.191.255 

Data format suports XML and JSON, just add a parameter of format:

http://api.locatorhq.com/?user=<username>&key=<apikey>&ip=<ipaddress>&format=xml 
http://api.locatorhq.com/?user=<username>&key=<apikey>&ip=<ipaddress>&format=json

For C# ASP.NET, you can get the data at code behind by using WebClient.

Example:

string url = "http://api.locatorhq.com/?user=john3041&key=27364b3d6060c9e0738754c9be60908ab00ac7&ip=64.233.191.255";
WebClient wc = new WebClient();
byte[] ba = wc.DownloadData(url);
string text = System.Text.Encoding.UTF8.GetString(ba); 

License

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

Share

About the Author

adriancs
Software Developer
Malaysia Malaysia
Writing programs is an art.

You may also be interested in...

Comments and Discussions

 
QuestionJust like any amateur API.... Pin
Axel Rietschin15-Jan-14 15:44
memberAxel Rietschin15-Jan-14 15:44 
GeneralNice, but not at all Pin
Lus Oliveira15-Jan-14 0:01
memberLus Oliveira15-Jan-14 0:01 
GeneralMessage Removed Pin
adriancs15-Jan-14 2:42
memberadriancs15-Jan-14 2:42 
GeneralRe: Nice, but not at all Pin
Lus Oliveira15-Jan-14 9:17
memberLus Oliveira15-Jan-14 9:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150731.1 | Last Updated 15 Jan 2014
Article Copyright 2014 by adriancs
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid