To get the value of a CS2 inventory, load every page of the inventory, take the Steam Community Market price of each item, multiply it by the item's amount and add everything up. With the inventory endpoint of Steam API Hub the prices already come with the items, so the whole calculation is one loop over one endpoint. This guide shows it in curl, JavaScript and Python.
CS2 has the app id 730. This request returns the first 2000 items with prices in US dollars:
1curl "https://api.steamapihub.com/inventory?appId=730&steamId=76561198000000000&count=2000¤cy=USD&apiKey=YOUR_API_KEY"
A shortened response:
1{2"status": "OK",3"hasMoreItems": false,4"lastAssetId": null,5"totalInventoryCount": 412,6"hiddenItemsOnPage": 3,7"visibleItemsOnPage": 409,8"data": [9{10"assetId": "41234567890",11"marketHashName": "AK-47 | Redline (Field-Tested)",12"amount": 1,13"isTradable": true,14"isMarketable": true,15"lowestSellOrder": 38.52,16"highestBuyOrder": 37.917}18]19}
The fields that matter for the value:
Both prices are left out of an item when we have no price for it, for example for items that cannot be sold on the market. Count those separately instead of treating them as zero.
The count parameter sets how many items one request asks for: at least 75, at most 2000, 75 by default. Use 2000. Each page is one request against your plan's limits, so an inventory of 5000 items costs three requests instead of 67.
Node 18 ships fetch, so there are no dependencies. Prices are summed in cents to avoid floating point drift.
1const API_URL = "https://api.steamapihub.com/inventory";2const API_KEY = process.env.STEAMAPIHUB_API_KEY;3async function getInventoryValue(steamId, currency = "USD") {4const params = new URLSearchParams({5appId: "730",6steamId,7count: "2000",8currency,9apiKey: API_KEY,10});11let sellCents = 0;12let buyCents = 0;13let items = 0;14let unpriced = 0;15let hasMoreItems = true;16while (hasMoreItems) {17const res = await fetch(`${API_URL}?${params}`);18const body = await res.json();19if (!res.ok) {20throw new Error(`${res.status} ${body.status}: ${body.error}`);21}22for (const item of body.data) {23items += item.amount;24if (item.lowestSellOrder === undefined) {25unpriced += item.amount;26continue;27}28sellCents += Math.round(item.lowestSellOrder * 100) * item.amount;29buyCents += Math.round((item.highestBuyOrder ?? 0) * 100) * item.amount;30}31hasMoreItems = body.hasMoreItems;32if (hasMoreItems) params.set("startAssetId", body.lastAssetId);33}34return {35items,36unpriced,37sellValue: sellCents / 100,38instantSellValue: buyCents / 100,39};40}41getInventoryValue("76561198000000000").then(console.log);
The same logic with the requests library.
1import os2import requests3API_URL = "https://api.steamapihub.com/inventory"4API_KEY = os.environ["STEAMAPIHUB_API_KEY"]5def get_inventory_value(steam_id, currency="USD"):6params = {7"appId": "730",8"steamId": steam_id,9"count": 2000,10"currency": currency,11"apiKey": API_KEY,12}13sell_cents = buy_cents = items = unpriced = 014while True:15res = requests.get(API_URL, params=params, timeout=60)16body = res.json()17if not res.ok:18raise RuntimeError(f"{res.status_code} {body.get('status')}: {body.get('error')}")19for item in body["data"]:20items += item["amount"]21sell = item.get("lowestSellOrder")22if sell is None:23unpriced += item["amount"]24continue25sell_cents += round(sell * 100) * item["amount"]26buy_cents += round(item.get("highestBuyOrder", 0) * 100) * item["amount"]27if not body["hasMoreItems"]:28break29params["startAssetId"] = body["lastAssetId"]30return {31"items": items,32"unpriced": unpriced,33"sell_value": sell_cents / 100,34"instant_sell_value": buy_cents / 100,35}36print(get_inventory_value("76561198000000000"))
There is no single correct value, so the code returns two:
If the inventory has items without a price, report the unpriced count next to the total so nobody reads a partial sum as the full value.
Every error response has a status and an error field. The examples above throw on every non-2xx answer, which is fine for a script. For handling 429 with retries, see Steam inventory rate limits and HTTP 429 errors.
Steam hides some items from other users, and they are not returned. The response tells you how many: hiddenItemsOnPage per page, and totalInventoryCount for the whole inventory including hidden items.
Yes. Set the currency parameter, for example currency=EUR. The API supports 41 currencies; without the parameter prices are in USD.
Yes. The endpoint works for any Steam game with an inventory: change appId, for example 570 for Dota 2 or 440 for Team Fortress 2. The value logic stays the same.
One per page. With count=2000 an inventory of up to 2000 items needs a single request.