Some of my sheets used to track pricing are suddenly looking very strange. Does the order of the fields in the inventory API call returns change randomly?
API Result order changing?
Started by Xandora [2198440] on in Questions & Answers.
About this thread
Posts archived: 5 / 5 posts (100%) · the total is Torn's reply count + the opening post at the last fetch
Counted by TornLife from the archived posts.
- Archived posts
- 5
- Discussion span
- →
- People posting
- 2
- Likes on archived posts
- 5
- Authority score
- 42 / 100
- Historical score
- 15 / 100
- Story score
- 26 / 100
- Engagement score
- 44 / 100
I've not seen fields change order in calls like "profile". However, "inventory" is a continually changing list of items, and I would assume that call would be more likely to change order.
With the inclusion of the UID for weapons and armor, individual items can be distinguished (vs for example, all hammers grouped together by item ID 1).
It looks like this list is loosely sorted by item name ( the weapons / armor are out of order).
But ultimately, "inventory" is a list of objects. Each object has identifying information. Why not just read in the list each time and then link the results to your previous set (if that's what you're trying to do).
In other words, don't depend on the order of the items, but link them via the ID (most items) or UID (armor and weapons). If you're using a spreadsheet, read in the new elements and then use VLOOKUP (Excel or Google Sheets) to link the new items to your old items.
[image: gyazo.com]
With the inclusion of the UID for weapons and armor, individual items can be distinguished (vs for example, all hammers grouped together by item ID 1).
It looks like this list is loosely sorted by item name ( the weapons / armor are out of order).
But ultimately, "inventory" is a list of objects. Each object has identifying information. Why not just read in the list each time and then link the results to your previous set (if that's what you're trying to do).
In other words, don't depend on the order of the items, but link them via the ID (most items) or UID (armor and weapons). If you're using a spreadsheet, read in the new elements and then use VLOOKUP (Excel or Google Sheets) to link the new items to your old items.
[image: gyazo.com]
Here's a rough example of linking the data using spreadsheets. You would want these lists on separate sheets, I did it on one for the screenshot.
On the left is my old list of items with the old price. On the right is the new data I just pulled with the API. In column "new price" I put in a formula that is looking up the new price from the new data.
The formula says if the (old) UID is blank then lookup the (old) ID in column G and get the market price (the 8th column from G). Otherwise, if (old) UID is not blank, lookup the (old) UID in column H and get the market price (7th column from H). If neither one is found, return the text "Not Found".
[image: gyazo.com]
Of course, you'd want to read that data in properly and not leave the field tags in the data. I just copied and pasted it so you could easily see how it relates to the API call, and get an idea of how to do it.
If you use a lookup, the order of the data does not matter.
On the left is my old list of items with the old price. On the right is the new data I just pulled with the API. In column "new price" I put in a formula that is looking up the new price from the new data.
The formula says if the (old) UID is blank then lookup the (old) ID in column G and get the market price (the 8th column from G). Otherwise, if (old) UID is not blank, lookup the (old) UID in column H and get the market price (7th column from H). If neither one is found, return the text "Not Found".
[image: gyazo.com]
Of course, you'd want to read that data in properly and not leave the field tags in the data. I just copied and pasted it so you could easily see how it relates to the API call, and get an idea of how to do it.
If you use a lookup, the order of the data does not matter.
Actually, It was just my dummy self. I had moved some columns around in my Inventory API ingest sheet and completely forgot! :D
Thanks for the message, I ended up figuring it out. I had manually moved some columns and my aggregation sheet through a wobbly. Appreciate the time you took though :)