Skip to content

Instantly share code, notes, and snippets.

@hboon
Last active April 23, 2021 03:09
Show Gist options
  • Select an option

  • Save hboon/f4d7422b40e450df2dae10e61c6ad7be to your computer and use it in GitHub Desktop.

Select an option

Save hboon/f4d7422b40e450df2dae10e61c6ad7be to your computer and use it in GitHub Desktop.
Using IP Sidekick for geolocation in Google Sheets
//Using IP Sidekick for geolocation in Google Sheets
//hboon@motionobj.com
//https://ipsidekick.com
//Instructions:
//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;
}
@cnd2008

cnd2008 commented Mar 10, 2020

Copy link
Copy Markdown

I'm getting a error 404 code from https://ipsidekick.com

@hboon

hboon commented Mar 10, 2020

Copy link
Copy Markdown
Author

Should be good now

@birthbaum-erate-showcase-h

Copy link
Copy Markdown

error 404 code

@hboon

hboon commented Apr 23, 2021

Copy link
Copy Markdown
Author

Should be good now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment