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,  or contact me on our forum
About brucemcp 225 Articles
I am a Google Developer Expert and decided to investigate Google Apps Script in my spare time. The more I investigated the more content I created so this site is extremely rich. Now, in 2019, a lot of things have disappeared or don’t work anymore due to Google having retired some stuff. I am however leaving things as is and where I came across some deprecated stuff, I have indicated it. I decided to write a book about it and to also create videos to teach developers who want to learn Google Apps Script. If you find the material contained in this site useful, you can support me by buying my books and or videos.