geoipify


API Documentation

geoipify provides real-time, trustworthy and consistent data about a given IP address. there are multiple uses of our API. Get real-time information about your user's geography and adjust your user experience according to the user.

we currently have 2 types of APIs for our partners

  1. GeoIP info API
  2. Requester API

GeoIP Info API

As the name suggests, this API is used to get GeoIP information about the given IP address. Depending upon the use case, we have 2 HTTP methods to access the API


GET

This method is built to get single GeoIP information.

GET https://geoipify.com/api/ipinfo/{ CLIENT_IP }/{ YOUR_AUTH_KEY }

You will be needing our API auth key to access the API. Just send the IP address and auth key in params to fetch the GeoIP info. You can generate and revoke the auth key on the dashboard.


POST

This method is suitable to get multiple IP info in one request. Simply pass the IP addresses in an array and send it in the body of the request along with the auth key.

    POST
    var data = JSON.stringify({
        "ip": [
            "{ CLIENT_IP_1 }",
            "{ CLIENT_IP_2 }"
        ]
    });
                              
    var xhr = new XMLHttpRequest();
    
    xhr.addEventListener("readystatechange", function () {
        if (this.readyState === 4) {
            console.log(this.responseText);
        }
    });
                              
    xhr.open("POST", "https://geoipify.com/api/ipinfo");
    xhr.setRequestHeader("Content-Type", "application/json");
    xhr.setRequestHeader("x-api-key", "{ YOUR_AUTH_KEY }");
                              
    xhr.send(data);
                        
    POST                        
    <?php
    
    $request = new HttpRequest();
    $request->setUrl('https://geoipify.com/api/ipinfo');
    $request->setMethod(HTTP_METH_POST);
    
    $request->setHeaders(array(
      'x-api-key' => '{ YOUR_AUTH_KEY }',
      'Content-Type' => 'application/json'
    ));
    
    $request->setBody('{
        "ip":["{ CLIENT_IP }"]
    }');
    
    try {
      $response = $request->send();
    
      echo $response->getBody();
    } catch (HttpException $ex) {
      echo $ex;
    }
                        
    POST
    OkHttpClient client = new OkHttpClient();
    
    MediaType mediaType = MediaType.parse("application/json");
    RequestBody body = RequestBody.create(mediaType, "{\n\t\"ip\":[\"{ CLIENT_IP_1 }\",\"{ CLIENT_IP_2 }\"]\n}");
    Request request = new Request.Builder()
        .url("https://geoipify.com/api/ipinfo")
        .post(body)
        .addHeader("Content-Type", "application/json")
        .addHeader("x-api-key", "{ YOUR_AUTH_KEY }")
        .build();
                            
    Response response = client.newCall(request).execute();
                        
    POST
    require 'uri'
    require 'net/http'
                            
    url = URI("https://geoipify.com/api/ipinfo")
                            
    http = Net::HTTP.new(url.host, url.port)
                            
    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = 'application/json'
    request["x-api-key"] = '{ YOUR_AUTH_KEY }'
    request.body = "{\n\t\"ip\":[\"{ CLIENT_IP_1 }\",\"{ CLIENT_IP_2 }\"]\n}"
                            
    response = http.request(request)
    puts response.read_body
                        
    POST                        
    curl -X POST \
        https://geoipify.com/api/ipinfo \
        -H 'Content-Type: application/json' \
        -H 'x-api-key: { YOUR_AUTH_KEY }' \
        -d '{
            "ip":["{ CLIENT_IP_1 }","{ CLIENT_IP_2 }"]
        }'
                        

Requester API

This API is built for client-side implementation. No need to extract IP from your user just set up this API on page load and we take care of rest.

GET https://geoipify.com/api/ip/check/{ YOUR_AUTH_KEY }

Response

    {
        "countryISO": "USA",
        "countryCode": "US",
        "country": "United States",
        "capital": "Washington",
        "currency": "USD",
        "phoneCode": "1",
        "flag": "🇺🇸",
        "flagUnicode": "U+1F1FA U+1F1F8",
        "region": "VA",
        "city": "",
        "lat": 38.6583,
        "long": -77.2481,
        "timezone": "America/New_York",
        "currentTime": "February 14th 2020, 7:59:44 am",
        "currentTimeISO": "2020-02-14T07:59:44-05:00",
        "continentName": "America",
        "continentCode": "NA"
    }
                    
Get your free api key