Thursday, 30 May 2013

Get Location Based on IP Address

There are many vendor available in market that provides REST service to get Location based on IP Address. In our example we have used IPInfoDB.

Step 1) Create an account with IPInfoDB:

Once account is created, you will receive an Account Activation link from IPInfoDB:

Activate the account.

Step 2) Login into IPInfoDB and under Overview Tab, copy the API Key. Using this API Key we will    call IPInfoDB Rest API to get Location.

Step 3) Java Code:

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;

public class IPInfoDB {
 public static void main(String[] args) {
  new IPInfoDB().getClientLatLng("IP_ADDRESS");
 public void getClientLatLng(String ip){
  if(ip!=null && !ip.equals(""))
   try {
    DefaultHttpClient httpClient = new DefaultHttpClient();
    HttpPost postRequest = new HttpPost(
      "{YOUR_API_KEY}&ip=" + ip);
    HttpResponse response = httpClient.execute(postRequest);
    if (response.getStatusLine().getStatusCode() != 201) {
      * throw new RuntimeException("Failed : HTTP error code : " +
      * response.getStatusLine().getStatusCode());
     System.out.println("StatusCode: "
       + response.getStatusLine().getStatusCode());
    BufferedReader br = new BufferedReader(new InputStreamReader(
    String output;
    System.out.println("Output from Server .... \n");
    while ((output = br.readLine()) != null) {
   } catch (MalformedURLException e) {
   } catch (IOException e) {


StatusCode: 200
Output from Server .... 

IP Info DB

Thats it!
Categories: , , , , ,


  1. Nice valuable information….I got my IP address details from

  2. Great article...thanks a lot sunil..after a week struggle i found ur site..and it made things so easy

  3. After selecting google map location, it will be displayed on store front.OCMOD extension.Gmap Geo Address

  4. Tesão Fatal 2 As Panteras o maior taradão dos cinemas porno esta de volta o Dhones Portela e com as melhores atriz como Ju Panteras para abrilhantar a mais esse filme espetacular da Panteras. Muito mais quente que a primeira edição o segundo vem cheio de mulheres gatas e disposta a fazer de tudo que se relaciona ao sexo. Elas adoram uma gaganta profunda e pira a cabeça de seus taradinhos mais safadinhos que tem no mundo do sexo. E com time desse de gatas os caras estara bem preparados para dar aquela foda nesses safadinhos que adoram fazer aquela sacanagem .
    Tesão Fatal 2 As Panteras || Download do vídeo

  5. Ah, HOT LEGS! Now this is what the Golden Age of Adult Films is all about! Alessandro cassioli bob Chinn, by this point a veteran of adult alessandro cassioli cinema whose name just screams quality, directs a first-rate cast performing a first-rate script, alessandro cassioli shot by a first-rate crew of professionals. Alessandro cassioli not only does the film look alessandro cassioli terrific, full of clever camera work and sizzling sex scenes alessandro cassioli, it's just plain FUN!

  6. There are a few methods for finding your Ethernet and interchanges convention data.what is myip

  7. Many people may have heard the term IP Address, but few know what it actually means or how locating an IP Address can benefit a business. myip

  8. Thanks for the post, I am techno savvy. I believe you hit the nail right on the head.
    I am highly impressed with your blog. It is very nicely explained.
    Your article adds best knowledge to our Java Online Training from India. or learn thru Java Online Training from India Students.

  9. Thus, a general thought with respect to their clients' decision and perusing patterns is determined.
    what is the new wearable technology


Find me on Facebook! Follow me on Twitter!