How can I see the gem value of an item that I do not own?

How can I see the gem value of an item that I do not own? - Things I Can't Say Out Load Book on Green Textile

I can see how many gems an item in my inventory converts to when I turn it into gems. But is there any way to know how many gems I would get for an item I do not own?



Best Answer

tl;dr

Here's a bookmarklet that you can run on the Community Market page for an item to get its gem value:

javascript:var a=g_rgAssets[Object.keys(g_rgAssets)[0]],b=a[Object.keys(a)[0]],c=b[Object.keys(b)[0]],gem_action=c.owner_actions&&c.owner_actions.filter(function(d){return/javascript:GetGooValue/.test(d.link)})[0];if(gem_action){var matches=gem_action.link.match(/javascript:GetGooValue\( '%contextid%', '%assetid%', (\d+), (\d+), \d+ \)/);fetch("https://steamcommunity.com/auction/ajaxgetgoovalueforitemtype/?appid="+matches[1]+"&item_type="+matches[2]+"&border_color=0").then(function(d){return d.json()}).then(function(d){alert("This is worth "+d.goo_value+" gems")})["catch"](function(d){return console.error(d)})}else alert("This is worth 0 gems");

When you're on the Community Market page for an item, paste this into the URL bar (you might have to retype the javascript: portion). You can also save it as a bookmark, which you can just click on to run.


Explanation

As noted by Wok, you can get the number of gems an item is worth by passing the appropriate appid and item_type to this endpoint:

https://steamcommunity.com/auction/ajaxgetgoovalueforitemtype/?appid=219890&item_type=16

which in this example corresponds to my favorite profile background from the game Antichamber and returns this response:

{"success":1,"goo_value":"80"}

But as noted by Wok and an answer to a similar question, item_type isn't exactly predictable and depends on the game and the relative amounts of item types that they have.

How does the Steam inventory webpage figure out what item_type is?

It's pretty gross.

When you load your inventory, the webpage makes a few requests (one for each context in that inventory) to get a list of inventory items. These JSON responses contain the item_type for each item, but in the worst format possible.

Each inventory object in the descriptions array of the JSON response contains an owner_actions array, where each object has a link and a name. item_type is stored in that link.

Sticking to the Antichamber profile background example, here's the link with its item_type:

"owner_actions":
[
  {
    "link": "javascript:GetGooValue( '%contextid%', '%assetid%', 219890, 16, 0 )",
    "name": "Turn into Gems..."
  }
]

The click events on the Steam inventory page parse out that JavaScript URL to figure out what event handler to run. The function GetGooValue() doesn't actually exist.

In case you didn't see it, the third argument to this nonexistent function provides appid and the fourth argument provides item_type.

vomits

What about items not in your inventory?

The previous web requests depend on a user's inventory, which isn't helpful if you want to find the gem value of some arbitrary item.

However, Community Market pages have a global variable called g_rgAssets. Here's a truncated sample for our example:

{
  "753":
  {
    "6":
    {
      "6298989828":
      {
        ... [truncated]
        "owner_actions":
        [
          {
            "link": "javascript:GetGooValue( '%contextid%', '%assetid%', 219890, 16, 0 )",
            "name": "Turn into Gems..."
          }
        ],
        ... [truncated]

So there's a sole child called the inventory ID, which itself has a sole child corresponding to the context ID. That in turn has a sole child called something (I don't know what it corresponds to), and inside of that is the same owner_actions we saw earlier (among other things).

From there it's pretty easy to find that link, parse out the appid and item_type, and make the web request to find the gem value of that item.

Something to watch out for: you can't just select the link of the first object in owner_actions:

  • There can be more than one action in there, such as the "View badge progress" action for trading cards.
  • The "Turn into Gems..." action doesn't show up on items that don't have gem values.
  • Sometimes g_rgAssets doesn't have owner_actions at all.

The bookmarklet above has some rudimentary handling for these cases.




Pictures about "How can I see the gem value of an item that I do not own?"

How can I see the gem value of an item that I do not own? - I Can and I Will Text On Green Background
How can I see the gem value of an item that I do not own? - A Man Standing with a Can of Paint
How can I see the gem value of an item that I do not own? - Hand Holding Fishing Baits





Steam Gems Tutorial




More answers regarding how can I see the gem value of an item that I do not own?

Answer 2

  1. Find the appID of the game, e.g. 239350 for Spelunky.

appID

  1. Check the gem amount corresponding to a normal card (item_type=2) at:

https://steamcommunity.com/auction/ajaxgetgoovalueforitemtype/?appid=239350&item_type=2

normal card

  1. Check the gem amount corresponding to a foil card (item_type=2, border_color=1) at:

https://steamcommunity.com/auction/ajaxgetgoovalueforitemtype/?appid=239350&item_type=2&border_color=1

foil card

  1. Check the gem amount corresponding to an emoticon (item_type=10) at:

https://steamcommunity.com/auction/ajaxgetgoovalueforitemtype/?appid=239350&item_type=10

emoticon

  1. Check the gem amount corresponding to a profile background (item_type=17) at:

https://steamcommunity.com/auction/ajaxgetgoovalueforitemtype/?appid=239350&item_type=17

profile background

Caveat: item_type numbering can differ from one game to another:

  • the index of the first card is always 2,
  • the index of the first emoticon can change depending on the number of cards,
  • the index of the first profile background can change depending on the number of cards, the number of emoticons, and the existence of gaps in the numbering for unknown reasons.

So, adjust accordingly and check the other values if you have any doubt.

Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Ann H, Tima Miroshnichenko, ANTONI SHKRABA, Karolina Grabowska