//Using IP Sidekick for geolocation in Google Sheets
//1. In Google Sheets, under `Tools`, click `Script editor...`.
//2. Paste the contents of this file.
//3. Hit the `Save` button. You may be asked to give the project a name.
//4. In your spreadsheet, click on the desired cell and enter something like
//... `=resolveIP(A1)` where A1 is the cell you want to lookup.
//This uses the free plan which limits you to 1440 lookups/day.
//For a higher rate limit, look at our paid plans at https://ipsidekick.com
function resolveIP(ip) {
var url = "https://ipsidekick.com/" + ip;
var response = UrlFetchApp.fetch(url);
var json = JSON.parse(response.getContentText());
return json.country.code;
//These fields are available:
//return json.ip;
//return json.country.code;
//return json.country.name;
//return json.currency.code;
//return json.currency.decimals;
//return json.currency.name;
//return json.timeZone.gmtOffset;
//return json.timeZone.name;
//return json.holiday;