On Google Spreadsheet, how do you call the CIty, Country of an IP?

geolocation, google-apps-script, google-sheets, json

Solution

After some digging I've figured out how to do this.

Copy the `import_json_appsscript.js` script on https://gist.github.com/chrislkeller/5719258. This will be the script that will create the `ImportJSON()` function to a Google spreadsheet

Go to Google spreadsheet, on the menu bar got to Tools > Script Editor

Copy paste `import_json_appsscript.js` into the Script Editor and save it, Double check that you can see the `ImportJSON()` function on the Select function drop down menu.

On the Spreadsheet use function =ImportJSON(url, query, options), for example `=ImportJSON("http://freegeoip.net/json/75.148.30.137", "/city", "noHeaders")` to retrieve `Baltimore` from the FreeGeoIP call.

Hope that helps, it certainly answers my question.

Problem

I would like to know if there is a formula/script one could use on Google Spreadsheet to obtain the City,Location of an array of IP addresses. i.e lets imagine that each cell on column A has 100 IP addresses, what formula/script should I use on column B to get the respective city and location?

Original source