Last active
August 6, 2016 23:52
-
-
Save klightspeed/c1e15b29886847241214e4ec8eb9fecd to your computer and use it in GitHub Desktop.
Custom Google Sheets function for importing travel logs from EDSM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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