Free Geo IP API: Excel and GAS – the Daily REST library entry

Geo code from ip and host names

Today’s API is a straightforward query per row, meaning that data is retrieved from the API using the contents of a column as the query. In this case the host column provides the query data. The freegeoip API will take a host name and ip address and provide geolocation data for it. Here’s how to do it in bulk directly from Excel or Google Apps Script. In a future post, i’ll mashup this with integrating Excel with Google Maps and Google Earth to plot them directly on a map. This example can be found in the cDataSet.xlsm and downloaded from here

Library entry

        With .add(“freegeoip”)
            .add “restType”, erRestType.erQueryPerRow
            .add “url”, “http://freegeoip.net/json/”
            .add “results”, “”
            .add “treeSearch”, False
            .add “ignore”, “”
            .add “append”, “”
        End With



And the execution code looks like this

Public Sub testfreeGeoIP()
    generalDataSetQuery “freegeoip”, “freegeoip”, “host”
End Sub

and for Google apps script

function testfreeGeoIP() {
    mcpher.generalDataSetQuery (“freegeoip”, “freegeoip”, “host”);
}

The rest library is itself implemented as REST API and can be queried like this.
For more stuff like this, visit the ramblings site or the associated blog. If you have suggestion for particular API, vote for it on google moderator or contact me on our forum

Author: brucemcp

Leave a Reply

Your email address will not be published. Required fields are marked *