Skip to content

Instantly share code, notes, and snippets.

@chandsie
Created July 12, 2019 05:39
Show Gist options
  • Save chandsie/37e709ccaa27905e1c46fd0e984191af to your computer and use it in GitHub Desktop.
Save chandsie/37e709ccaa27905e1c46fd0e984191af to your computer and use it in GitHub Desktop.
Combining two GESI endpoints to get information on ores
function myFunction() {
var sheet = SpreadsheetApp.getActiveSheet();
var items = [];
// 25 == ores category
var catInfo = GESI.universe_categories_category(25, "en-us", false, "latest")[0];
JSON.parse(catInfo[1]).forEach(function(groupID) {
Logger.log(groupID);
var groupInfo = GESI.universe_groups_group(groupID, "en-us", false, "latest")[0];
var groupName = [groupInfo[2]];
var itemIDs = JSON.parse(groupInfo[4]);
// sheet.appendRow(groupName);
if (itemIDs === undefined || itemIDs.length == 0) {
Logger.log("no item IDs");
} else {
// sheet.appendRow(itemIDs);
items.push.apply(items, itemIDs);
}
});
items.forEach(function(itemID) {
var itemInfo = GESI.universe_types_type(itemID, "en-us", false, "latest")[0];
var name = itemInfo[9];
var volume = itemInfo[15];
var info = [name, itemID, volume];
sheet.appendRow(itemInfo);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment