Skip to content

Instantly share code, notes, and snippets.

@klightspeed
Last active August 6, 2016 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klightspeed/c1e15b29886847241214e4ec8eb9fecd to your computer and use it in GitHub Desktop.
Save klightspeed/c1e15b29886847241214e4ec8eb9fecd to your computer and use it in GitHub Desktop.
Custom Google Sheets function for importing travel logs from EDSM
// Imports travel logs from EDSM
// Usage: =ImportEDSMLogs("Commander Name","8c9e522d3bb0756a41d51146a6ae421d98a60742")
// cmdrname: Commander Name on EDSM
// apikey: API Key from https://www.edsm.net/settings/api
function ImportEDSMLogs(cmdrname,apikey) {
var url = "https://www.edsm.net/api-logs-v1/get-logs?commanderName=" + encodeURIComponent(cmdrname) + "&apiKey=" + apikey;
var data = JSON.parse(UrlFetchApp.fetch(url));
var ret = [];
if (data.msgnum == 100) {
data.logs.forEach(function(v,i,a) {
ret.push([v.date, v.system]);
});
return ret;
} else {
throw new Error(data.msg);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment