48

I am making a website that needs to access the Steam inventory of the user. I found an API to get Team Fortress 2 inventory, Dota 2, CS:S, CS:GO and Portal 2. But I didn't find any API for getting Steam inventory.

Is it possible to access a user's Steam inventory?

2 Answers 2

100

New Endpoint

There is a new end point for fetching inventories as of December 2016. The old one listed below still works (for now). Both seem to be highly ratelimited.

The new inventory path is:

http://steamcommunity.com/inventory/<PROFILEID>/440/2?l=english&count=5000

With this new path, l is the language you want to receive data back in and count is the number of items to receive back at a time. The maximum is 5000.

You can paginate with this new end point too:

http://steamcommunity.com/inventory/<PROFILEID>/440/2?l=english&count=5000&start_assetid=468336866

This will pull the next 5000 items starting with assetid 468336866.

The end point returns a large json object with the following structure:

{ 
    'assets': <list>,
    'descriptions': <list>,
    'total_inventory_count': integer,
    'success': 1/0,
    'rwgran': integer
}

I am not completely sure what rwgran is at this point.

The assets key, returns data that looks like this:

[{'amount': '1',
         'appid': '440',
         'assetid': '4985815666',
         'classid': '134',
         'contextid': '2',
         'instanceid': '0'},
        {'amount': '1',
         'appid': '440',
         'assetid': '4985815941',
         'classid': '22989188',
         'contextid': '2',
         'instanceid': '0'},
        ...
]

The descriptions key contains entries like this. Notice that this contains a lot for information than the old end point.

[{'actions': [{'link': 'http:\\/\\/wiki.teamfortress.com\\/scripts\\/itemredirect.php?id=241&lang=en_US',
                            'name': 'Item Wiki Page...'}],
               'appid': 440,
               'background_color': '3C352E',
               'classid': '134',
               'commodity': 0,
               'currency': 0,
               'descriptions': [{'type': 'text',
                                 'value': 'Is an enemy player questioning your skills, personal hygiene, and\\/or ancestry?\nUse these stylish firearms to challenge them to a duel!\nSee the Mann Co. Catalog for full details.'},
                                {'type': 'text', 'value': ' '},
                                {'color': '00a000',
                                 'type': 'text',
                                 'value': 'This is a limited use item.  Uses: 5'}],
               'icon_url': 'fWFc82js0fmoRAP-qOIPu5THSWqfSmTELLqcUywGkijVjZULUrsm1j-9xgECbwgfYh_3vTRKhs_ZAfOeD-VOyo4z4clTizJqwQcpYOHnNDFmcweRVqQPCqVq91C-WCM26pFnB4PjofUWJ1uAGDnHsA',
               'icon_url_large': 'fWFc82js0fmoRAP-qOIPu5THSWqfSmTELLqcUywGkijVjZULUrsm1j-9xgECbwgfYh_3vTRKhs_ZAfOeD-VOyo4z4clTizJqwQcpYOHnNDFmcweRVqQPCqVq91C-WCM26pFnB4PjofUWJ1uAGDnHsA',
               'instanceid': '0',
               'market_hash_name': 'Dueling Mini-Game',
               'market_marketable_restriction': 0,
               'market_name': 'Dueling Mini-Game',
               'market_tradable_restriction': 7,
               'marketable': 0,
               'name': 'Dueling Mini-Game',
               'name_color': '7D6D00',
               'tags': [{'category': 'Quality',
                         'color': '7D6D00',
                         'internal_name': 'Unique',
                         'localized_category_name': 'Quality',
                         'localized_tag_name': 'Unique'},
                        {'category': 'Type',
                         'internal_name': 'TF_UsableItem',
                         'localized_category_name': 'Type',
                         'localized_tag_name': 'Usable Item'},
                        {'category': 'Class',
                         'internal_name': 'Scout',
                         'localized_category_name': 'Class',
                         'localized_tag_name': 'Scout'},
                        {'category': 'Class',
                         'internal_name': 'Sniper',
                         'localized_category_name': 'Class',
                         'localized_tag_name': 'Sniper'},
                        {'category': 'Class',
                         'internal_name': 'Soldier',
                         'localized_category_name': 'Class',
                         'localized_tag_name': 'Soldier'},
                        {'category': 'Class',
                         'internal_name': 'Demoman',
                         'localized_category_name': 'Class',
                         'localized_tag_name': 'Demoman'},
                        {'category': 'Class',
                         'internal_name': 'Medic',
                         'localized_category_name': 'Class',
                         'localized_tag_name': 'Medic'},
                        {'category': 'Class',
                         'internal_name': 'Heavy',
                         'localized_category_name': 'Class',
                         'localized_tag_name': 'Heavy'},
                        {'category': 'Class',
                         'internal_name': 'Pyro',
                         'localized_category_name': 'Class',
                         'localized_tag_name': 'Pyro'},
                        {'category': 'Class',
                         'internal_name': 'Spy',
                         'localized_category_name': 'Class',
                         'localized_tag_name': 'Spy'},
                        {'category': 'Class',
                         'internal_name': 'Engineer',
                         'localized_category_name': 'Class',
                         'localized_tag_name': 'Engineer'}],
               'tradable': 1,
               'type': 'Level 5 Usable Item'},
      ...
]

As with the old method, the assets and descriptions are linked via the classid in both.


Old Endpoint

Update: This Endpoint is partialy unvailable since November 11th 2022, 00:00 CET

This endpoint will return { "success": false, "Error": "Unsupported request" } in some regions (depends on account region). It's expected, that all regions will shut down this endpoint in the near future.

You can get some limited information if the target has their profile permissions set appropriately.

You can view the resulting json files by using either of these two links for beta (and gift, if appropriate permissions are set) inventories

http://steamcommunity.com/id/<CUSTOMURL>/inventory/json/753/1 http://steamcommunity.com/profiles/<PROFILEID>/inventory/json/753/1

CUSTOMURL is the user friendly name the player has selected to use. This is changeable by the player at any time. If you are writing a web page, I assume you know how to get this piece of information, correct? PROFILEID is the 64Bit id that a player is given by Steam when you create the account. This is not changeable and it is returned by Steam when they log in using an OpenID implementation.

When using those URLs, there are a few possible responses. The first is if the user has their profile set to private.

{"success":false,"Error":"This profile is private."}

The second is a listing of "stuff" in the inventory

{
    "success":true,
    "rgInventory":
    {
        "1586670077416875609":
        {
            "id":"1586670077416875609",
            "classid":"149742033",
            "instanceid":"0",
            "amount":"1",
            "pos":1
        },
        "1586670077416875905":
        {
            "id":"1586670077416875905",
            "classid":"149742033",
            "instanceid":"0",
            "amount":"1",
            "pos":2
        },
        "1586670077416877092":
        {
            "id":"1586670077416877092",
            "classid":"149742033",
            "instanceid":"0",
            "amount":"1",
            "pos":3
        }
    },
    "rgCurrency":[],
    "rgDescriptions":
    {
        "149742033_0":
        {   "appid":"753",
        "classid":"149742033",
        "instanceid":"0",
        "icon_url":"ZyjGwQD4ogROtSm7KvtdP99kDHBEiKxKm3Gg7pMaBJyiPu4iS_PzF6QhOUdOwk-m0WhXYQ7X8AbNL6Hz1VxOnq4-8iBC5MlBuXMuElaaCrHQLww9T5S1Ecoqo_PYWg==",
        "icon_url_large":"a6FEz5nbBlvu8bGd1oDggdPtjn7dqwgVOzU4yG9huSKut2ws0tBXSARloWGyufIY3eHVb5f0VFltaznVKSfzK6amZz7FjFhcTTm6Maz860eOrMo937A=",
        "icon_drag_url":"",
        "name":"Steam Trading Card Beta",
        "market_name":"",
        "name_color":"",
        "background_color":"",
        "type":"Gift",
        "tradable":1,
        "marketable":0,
        "descriptions":[
            {"value":"Steam Trading Card Beta Access - Extra Copy"},
            {"value":"Grants early access to the Steam Trading Cards beta, game badges, and the new profile. Join the Steam Trading Cards Group and post your feedback in the Discussions area. Select \u201cAdd to my game library\u201d to activate."}
            ],
        "actions":[
            {"name":"View in store","link":"http:\/\/steamcommunity.com\/tradingcards"}
            ]
        }
    }
}

If the URL is for YOUR ID and you are logged into Steam, you can also see items that are listed as Gift. Otherwise, those are hidden by default.

Since this isn't an official API, there isn't much documentation about this particular schema. However, it appears that the items in rgInventory are linked to items in the reDescriptions by classid. Writing the parser is left as an exercise for the reader.

These shows the beta accesses.

If you are looking for trading card information, change the 1 in the above URLs to a 6

http://steamcommunity.com/id/<CUSTOMURL>/inventory/json/753/6 http://steamcommunity.com/profiles/<PROFILEID>/inventory/json/753/6

The schema layouts appear to be the same for these.

14
  • Just curious, how did you know this JSON data existed? How did you know about these links? Are they provided by Steam so users can manipulate their inventories?
    – jlcv
    Commented Aug 27, 2014 at 7:40
  • 3
    @JustinLiang Lots of poking at the Steam Services. There may be documentation now, but when I wrote this, it was poking at the web UI and seeing what made it tick.
    – Andy
    Commented Aug 27, 2014 at 13:10
  • 1
    It is private. You don't get it, because they set it so that you can't.
    – Andy
    Commented Oct 17, 2014 at 16:14
  • 4
    Note that there's been a change in how inventories are displayed and now the given URL format only retrieves the first 2500 inventory items. It is necessary to append ?start=#### at the end of the URL to retrieve the next set of items. For example?start=2500. This is necessary to get complete data for very large inventories.
    – Chrisuu
    Commented Sep 17, 2015 at 2:08
  • 1
    It seems like /2 (http://steamcommunity.com/id/<CUSTOM_URL>/inventory/json/730/2/) gives you their ordinary inventory contents.
    – Jeremy
    Commented Nov 28, 2016 at 0:03
18

Just to precise Andy's answer, the schema is:

http://steamcommunity.com/profiles/<PROFILEID>/inventory/json/<APPID>/<CONTEXTID>

App ID identifies the game/application this inventory is related to : here's the list.

Context ID filters the items, it varies from game to game.

Another thing: the items returned are uniquely identified by the classid-instanceid pair (source), so when you link them with their description, you should take both into account.

3
  • Copying my comment on Andy's post: Did you ever figure out how to query for a specific, given item? Any combination of inputs about the item would be fine. start_assetid is frustratingly close but it does not actually include in the response the assetId providing in the request, which is what i'd want.
    – Reciever80
    Commented Aug 25, 2019 at 19:59
  • @Jrs42 is there any way to know how many context ID's must be queried to get complete list of items? I found that value 2 works for most games but there could be more.... Commented Mar 4, 2020 at 6:54
  • I don't know of a public API for accessing the list of contexts for a specific app and user (contexts are user specific but implementation is left to the app's developer). If you look at steamcommunity's website source, they simply inject a global variable named g_rgAppContextData into the page's body which lists available contexts.
    – Jrs42
    Commented Mar 4, 2020 at 12:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.