ImportJSON to Google Sheets

Hello, everyone!
Since evemarketer.com have problems (market aggregator return error when trying retrive data with “usesystem”), i try use fuzzwork API, but there not XML :frowning: I am not familiar with programming and can’t figure out how to make Fuzzwork’s API work correctly.
The problem is that I can not import the desired array. For ImportJSON I use this script - https://gist.github.com/paulgambill/cacd19da95a1421d3164
There example of how I try to do it - https://docs.google.com/spreadsheets/d/1ToqiEqkYUu3jzbNK-LjDT5kyQF6kG7p9N7PvwsNQUVs/edit?usp=sharing
Hope someone can help me and sorry for bad english.

/**
* Query's Fuzz market API for the given types
* @param {range} A vertical range of type_ids.
* @return maxBuy and minSell for each type_id
* @customfunction
*/
function fuzzApiPriceData(type_ids) {
  if (!type_ids) throw 'type_ids is required';
  var type_ids = Array.isArray(type_ids) ? type_ids.map(function(id) { return id[0]; }) : [type_ids];
  var fuzz_price_data = JSON.parse(UrlFetchApp.fetch("https://market.fuzzwork.co.uk/aggregates/?station=60003760&types=" + type_ids.join(',')));
  return [['minSell', 'maxBuy']].concat(type_ids.map(function(type_id) { return [parseFloat(fuzz_price_data[type_id]['sell']['min']), parseFloat(fuzz_price_data[type_id]['buy']['max'])]; }));
}

Can copy/paste this into your sheets script editor, Tools => Script Editor.

Then you can use it by passing it a vertical range of IDs to get prices for. By default the function is getting min sell and max buy in Jita.

=fuzzApiPriceData(A1:A500)

Suggested way to use this would be have a sheet for static data, like type_id and type_name, then use this function to get price data for those items. This would allow you to then easily use vlookup to get the prices/name of a type_id.

1 Like

Thank you! It’s working. I suppose this will not work with Perimeter (system) or Tranquillty Trading Tower (structure)?

See https://pr.reddit.com/r/evetech/comments/get652/spreadsheets_are_hard/fprlp7n/ for handling structures.

1 Like

this function returns me an error:
ReferenceError: GESI is not defined (line 10).

Ah yes, you’ll need to install GESI. Can follow these steps: https://github.com/Blacksmoke16/GESI#script-editor.

1 Like

Oh. I fogget to Add a library. Now it’s work perfect!
BTW, this function get data from ESI without any of agreggator? Not depending on Fuzzwork status?

Correct. However because of that, it’s not as easy to use (only 1 ID at a time). Also sheets has a limit on the number of requests that can be made per day. So just be mindful of that.

I did link this on the api page on my site. along with a sample sheet.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.