# How to import market data into a spreadshit?

**URL:** <https://forums.eveonline.com/t/how-to-import-market-data-into-a-spreadshit/135663>\
**Category:** Third Party Developers\
**Created:** [January 24, 2019, 2:50pm UTC](https://forums.eveonline.com/t/how-to-import-market-data-into-a-spreadshit/135663 "2019-01-24T14:50:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jean\_Duchesnois](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/jean_duchesnois/32/359825_2.png) [@Jean\_Duchesnois](https://forums.eveonline.com/u/Jean_Duchesnois)\
**Post date:** [January 24, 2019, 2:50pm UTC](https://forums.eveonline.com/t/how-to-import-market-data-into-a-spreadshit/135663/1 "2019-01-24T14:50:40Z")

</div>

I suppose this is a common question but I can’t find answers that are understandable by the complete rookie that I am, or not outdated.

My goal is to do some calculations that are including the Jita prices of a few items without having to update every price manually, which is long and tedious.

So I would like to pull the prices of the given items into a calc sheet automatically but I don’t know how to do so. I’ve read that I could use the ESI or Fuzzwork API but this is arcane to me so if someone could explain me slowly how to proceed it would be very appreciated.

Regards

---

<div class="post-metadata">

**Author:** ![ISD\_Sakimura](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/isd_sakimura/32/382213_2.png) [@ISD\_Sakimura](https://forums.eveonline.com/u/ISD_Sakimura)\
**Post date:** [January 24, 2019, 3:43pm UTC](https://forums.eveonline.com/t/how-to-import-market-data-into-a-spreadshit/135663/2 "2019-01-24T15:43:20Z")

</div>

To use ESI to achieve your goal is complicated as you cannot request a single typeid but only the entire market for the Region/System/Station, also to the fact that the return type is in JSON format which you would have to convert to other format to extract your desired information or somehow import it directly into your spreadsheet and use it’s functionality to extract the information.

Using Fuzzwork API or [EVEmarketer.com](http://EVEmarketer.com) API as I’m used to is way easier, while it may not be 100% accurate it’s well within the margin of error that you could expect.

To get the price for an XML-API you would use the function IMPORTXML(url, “xml-path”), so in case of the api I use it will look like this:

> =IMPORTXML([http://api.evemarketer.com/ec/marketstat?typeid=34&usesystem=30000142](http://api.evemarketer.com/ec/marketstat?typeid=34&usesystem=30000142), “//Sell/min”)  
> \*_This one will give lowest price on Tritanium in Jita market_

To use this you’d need to know the typeid of the items you’re pulling prices on, or if you want to automate you’d need to have a database sheet with all typeids and the corresponding names and then do a VLOOKUP() to get typeid by simply typing in the item’s name, it’s recommended to do datavalidation for your input cells and have it checked against the names in the database.

> VLOOKUP(search\_key, range, index, [is\_sorted])

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/blacksmoke16/32/376589_2.png) [@Blacksmoke16](https://forums.eveonline.com/u/Blacksmoke16)\
**Post date:** [January 24, 2019, 6:17pm UTC](https://forums.eveonline.com/t/how-to-import-market-data-into-a-spreadshit/135663/3 "2019-01-24T18:17:08Z")

</div>

Assuming you’re on Google Sheets.

Just add this to your script editor:

```auto
/**
* 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'])]; }));
}

```

Then you can use it by `=fuzzApiPriceData(A1:A100)`. Where `A1:A100` is the type\_ids you want prices for.

Then as @ISD_Sakimura said, can use vlookup to get prices where you need them.

---

<div class="post-metadata">

**Author:** ![Jean\_Duchesnois](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/jean_duchesnois/32/359825_2.png) [@Jean\_Duchesnois](https://forums.eveonline.com/u/Jean_Duchesnois)\
**Post date:** [January 24, 2019, 11:27pm UTC](https://forums.eveonline.com/t/how-to-import-market-data-into-a-spreadshit/135663/4 "2019-01-24T23:27:24Z")

</div>

Thank you very much ! I search a bit and managed to figure out what you’re talking about, thanks !

I found a type\_ids database and manage to fit it in the sheet, VLOOKUP didn’t work but it worked with INDEX(MATCH()) so in the end it’s working, and thanks to Blacksmoke16 scripts (that is total arcane to me I must say) I can pull the prices of the items that I want.

However, I still have some questions 🙂

First, the =IMPORTXML isn’t working, it returns an error message and I can’t figure out why.

Second, are these prices from Jita ? They seem to be close but don’t exactly match, is this because of the API refresh time ?

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/blacksmoke16/32/376589_2.png) [@Blacksmoke16](https://forums.eveonline.com/u/Blacksmoke16)\
**Post date:** [January 24, 2019, 11:48pm UTC](https://forums.eveonline.com/t/how-to-import-market-data-into-a-spreadshit/135663/5 "2019-01-24T23:48:36Z")

</div>

If you’re using mine you dont really have a reason to use the `=IMPORTXML`. Yes they are from jita, but may be slightly out of date as they will only update every 30min.

---

<div class="post-metadata">

**Author:** ![Jean\_Duchesnois](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/jean_duchesnois/32/359825_2.png) [@Jean\_Duchesnois](https://forums.eveonline.com/u/Jean_Duchesnois)\
**Post date:** [January 25, 2019, 11:25am UTC](https://forums.eveonline.com/t/how-to-import-market-data-into-a-spreadshit/135663/6 "2019-01-25T11:25:35Z")

</div>

> [@Blacksmoke16](#):
>
> If you’re using mine you dont really have a reason to use the `=IMPORTXML` . Yes they are from jita, but may be slightly out of date as they will only update every 30min.

Yes, it works like a charm but I’m wondering why =IMPORTXML isn’t working aswell, after all I may need it in the future. Google sheet underlines the // before sell in red, telling that it can’t read this command in this context, so I suppose this is the problem ?

About your script it looks amazing, I’ve been staying a bit on it trying to understand what it does, I guess the first line returns an error message in case of missing typie\_ids, the 3rd line fetch the data from the URL and the 4th one pick what I want among all the data and displays it. However I don’t know what the 2nd line is doing. Which language is this ? Maybe I could learn the basics to modify the script to adapt it to my needs.

Actually that’s intresting, EVE taught me English and now again I’m learning a thing or two ^^

---

<div class="post-metadata">

**Author:** ![ISD\_Sakimura](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/isd_sakimura/32/382213_2.png) [@ISD\_Sakimura](https://forums.eveonline.com/u/ISD_Sakimura)\
**Post date:** [January 25, 2019, 12:55pm UTC](https://forums.eveonline.com/t/how-to-import-market-data-into-a-spreadshit/135663/7 "2019-01-25T12:55:22Z")

</div>

Did you include the quotation symbols in the function’s parentheses? as in _“//sell/min”_ and not just _//sell/min_

> [@Jean\_Duchesnois](#):
>
> However I don’t know what the 2nd line is doing.

It’s making an Array of type\_ids from a range you specify; example A2:A10 will become [A2,A3,A4,A5,A6,A7,A8,A9,A10].  
then line 3 combines with the url and each value in the array separated with a “,” then the API will return price data for those type\_ids to be worked on further…

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/blacksmoke16/32/376589_2.png) [@Blacksmoke16](https://forums.eveonline.com/u/Blacksmoke16)\
**Post date:** [January 25, 2019, 1:16pm UTC](https://forums.eveonline.com/t/how-to-import-market-data-into-a-spreadshit/135663/8 "2019-01-25T13:16:28Z")

</div>

The second line determines if you have it a single value or a range of values. If its a range of values, it assumes it is a vertical range, and parses out the ids from that range. Otherwise if its not a range, it just adds that single value to an array. All of this is so that I can call `.join` on the array.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/eveonline/original/3X/4/1/41ec4921cbaca7a6f9ea556e7cc20018461eae5e.png) [@system](https://forums.eveonline.com/u/system)\
**Post date:** [April 25, 2019, 1:16pm UTC](https://forums.eveonline.com/t/how-to-import-market-data-into-a-spreadshit/135663/9 "2019-04-25T13:16:29Z")

</div>

Closed on April 25, 2019, 1:16pm UTC

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