Steam Community Inventory Skill
Retrieve and browse a Steam user's inventory from steamcommunity.com.
Setup
- 1. Find your Steam ID (SteamID64):
- Go to your Steam profile page
- If your URL is
https://steamcommunity.com/profiles/76561198012345678, your Steam ID is
76561198012345678
- If your URL uses a vanity name like
https://steamcommunity.com/id/myname, visit
steamid.io and paste your profile URL to get your SteamID64
- 2. Get your Steam session cookies (required to bypass rate limits when fetching your own inventory):
- Log in to
steamcommunity.com in your browser
- Open Developer Tools (F12) > Application tab > Cookies >
https://steamcommunity.com
- Copy the value of the
steamLoginSecure cookie
- 3. Set environment variables:
CODEBLOCK0
Usage
All commands use curl to hit the Steam Community inventory endpoint. The context ID is 2 for all standard game inventories.
Common App IDs
| Game | App ID |
|---|
| CS2 / CS:GO | 730 |
| Team Fortress 2 |
440 |
| Dota 2 | 570 |
| Rust | 252490 |
| PUBG | 578080 |
| Steam Community (trading cards, etc.) | 753 |
Get inventory for a game
Replace $APP_ID with the game's App ID (see table above). Context ID is 2 for all standard game inventories.
CODEBLOCK1
Get CS2 inventory
CODEBLOCK2
Get a summary of items (names and quantities)
CODEBLOCK3
Get item details (asset IDs mapped to descriptions)
CODEBLOCK4
Paginated fetch (for inventories over 2000 items)
The API returns a last_assetid field when there are more items. Pass it as start_assetid to get the next page:
CODEBLOCK5
Check for more pages by looking at the more_items field in the response (equals 1 if there are more).
Response Format
The inventory endpoint returns JSON with these key fields:
| Field | Description |
|---|
| INLINECODE12 | Array of items with appid, contextid, assetid, classid, instanceid, INLINECODE18 |
| INLINECODE19 |
Array of item metadata:
market_hash_name,
name,
type,
icon_url,
tradable,
marketable, tags, etc. |
|
total_inventory_count | Total number of items in the inventory |
|
more_items |
1 if more pages available (absent otherwise) |
|
last_assetid | Last asset ID returned; use as
start_assetid for next page |
|
success |
1 if the request succeeded |
Assets are linked to descriptions via classid + instanceid.
Notes
- - Rate limits: The community endpoint is heavily rate-limited by IP. Using your own cookies bypasses this for your own inventory. Without cookies, expect IP bans after a few requests (cooldown ~6 hours).
- Spacing: If fetching multiple inventories or pages, wait at least 4 seconds between requests.
- count parameter: Max value is 5000, but 2000 is recommended to avoid issues.
- Context ID: Use
2 for all standard game inventories. Steam Community items (appid 753) also use context ID 6 for some item types. - Private profiles: Inventory must be set to public, or you must be authenticated as the owner.
Steam社区库存技能
从steamcommunity.com检索和浏览Steam用户的库存。
设置
- 1. 找到你的Steam ID(SteamID64):
- 前往你的Steam个人资料页面
- 如果你的URL是https://steamcommunity.com/profiles/76561198012345678,你的Steam ID就是76561198012345678
- 如果你的URL使用自定义名称如https://steamcommunity.com/id/myname,请访问
steamid.io并粘贴你的个人资料URL以获取SteamID64
- 2. 获取你的Steam会话Cookie(在获取自己的库存时绕过速率限制所需):
- 在浏览器中登录
steamcommunity.com
- 打开开发者工具(F12)> 应用程序标签 > Cookie > https://steamcommunity.com
- 复制steamLoginSecureCookie的值
- 3. 设置环境变量:
bash
export STEAM_ID=你的-steamid64
export STEAM_COOKIES=steamLoginSecure=你的-cookie-值
使用方法
所有命令均使用curl访问Steam社区库存端点。所有标准游戏库存的上下文ID均为2。
常见应用ID
| 游戏 | 应用ID |
|---|
| CS2 / CS:GO | 730 |
| 军团要塞2 |
440 |
| Dota 2 | 570 |
| 腐蚀 | 252490 |
| 绝地求生 | 578080 |
| Steam社区(交易卡等) | 753 |
获取某个游戏的库存
将$APP_ID替换为游戏的应用ID(见上表)。所有标准游戏库存的上下文ID均为2。
bash
curl -s https://steamcommunity.com/inventory/$STEAMID/$APPID/2?l=english&count=2000 \
-H Cookie: $STEAM_COOKIES | jq .
获取CS2库存
bash
curl -s https://steamcommunity.com/inventory/$STEAM_ID/730/2?l=english&count=2000 \
-H Cookie: $STEAM_COOKIES | jq .
获取物品摘要(名称和数量)
bash
curl -s https://steamcommunity.com/inventory/$STEAM_ID/730/2?l=english&count=2000 \
-H Cookie: $STEAMCOOKIES | jq [.descriptions[] | {markethash_name, type}]
获取物品详情(资产ID映射到描述)
bash
curl -s https://steamcommunity.com/inventory/$STEAM_ID/730/2?l=english&count=2000 \
-H Cookie: $STEAMCOOKIES | jq {assets: [.assets[] | {assetid, classid, instanceid, amount}], total: .totalinventory_count}
分页获取(适用于超过2000件物品的库存)
当有更多物品时,API会返回lastassetid字段。将其作为startassetid传递以获取下一页:
bash
curl -s https://steamcommunity.com/inventory/$STEAMID/730/2?l=english&count=2000&startassetid=$LASTASSETID \
-H Cookie: $STEAM_COOKIES | jq .
通过检查响应中的more_items字段(如果还有更多则为1)来判断是否有更多页面。
响应格式
库存端点返回包含以下关键字段的JSON:
| 字段 | 描述 |
|---|
| assets | 物品数组,包含appid、contextid、assetid、classid、instanceid、amount |
| descriptions |
物品元数据数组:market
hashname、name、type、icon_url、tradable、marketable、标签等 |
| total
inventorycount | 库存中的物品总数 |
| more_items | 如果还有更多页面则为1(否则不出现) |
| last
assetid | 返回的最后一个资产ID;用作下一页的startassetid |
| success | 如果请求成功则为1 |
资产通过classid + instanceid链接到描述。
注意事项
- - 速率限制:社区端点对IP有严格的速率限制。使用自己的Cookie可以绕过对自己库存的限制。如果没有Cookie,几次请求后可能会遭遇IP封禁(冷却时间约6小时)。
- 间隔:如果获取多个库存或页面,请求之间至少等待4秒。
- count参数:最大值为5000,但建议使用2000以避免问题。
- 上下文ID:所有标准游戏库存使用2。Steam社区物品(应用ID 753)对于某些物品类型也使用上下文ID 6。
- 私密个人资料:库存必须设置为公开,或者你必须以所有者身份进行身份验证。