Blog · Updated 21 July 2026 · Tutorial
How to Build a CS2 Inventory Value Calculator
One of the most-requested CS2 tools answers a simple question: “what is my inventory worth?” With the Steam Data API you can build one in about 30 lines - it reads a public inventory, prices every skin, and hands you a ready-made total in the currency you choose.
What you'll need
- An API key from your dashboard. Inventory lookups are on the Pro+ plan and up.
- A Steam ID (64-bit), profile URL, or vanity name. The CS2 inventory must be public.
- Any HTTP client - the examples below use
fetchin Node.js.
Step 1 - Read the inventory
The inventory endpoint takes the Steam ID in the path and does the heavy lifting: it live-fetches the player's items,
prices each one, and computes the totals. Pass a currency and everything converts on the fly.
const KEY = 'sdk_your_key';
const steamid = '76561198000000000';
const res = await fetch(
`https://steamdataapi.com/api/v1/inventory/${steamid}?game=cs2¤cy=USD`,
{ headers: { Authorization: `Bearer ${KEY}` } },
);
const inv = await res.json();
Step 2 - Read the total (it's already computed)
You don't have to sum anything: the response's summary.totalValue.steamPrice is the whole inventory
valued at Steam Community Market prices, in integer cents. Divide by 100 only when you display.
const cents = inv.summary.totalValue.steamPrice;
console.log(`Inventory value: $${(cents / 100).toFixed(2)}`);
// e.g. summary: { items: 708, totalInventoryCount: 723, totalValue: { steamPrice: 3984210 } }
steamPrice undervalues those.
Add ?markets=1 and you also get summary.totalValue.realAvg: the inventory valued at the
mean across the third-party markets, uncapped. See
Steam price vs. real market value for which to show when.Step 3 - Show a top-holdings breakdown
For a nicer UI, sort the items by their per-item value and show the biggest holdings. Each item carries
marketHashName, the exterior, StatTrak™ / souvenir flags, an image URL, and a
prices object - prices.value is our per-item fair value (phase-aware for Dopplers).
Remember amount for stacked items like cases and capsules.
const top = [...inv.items]
.sort((a, b) => (b.prices?.value ?? 0) - (a.prices?.value ?? 0))
.slice(0, 10);
for (const it of top) {
const v = (it.prices?.value ?? 0) * (it.amount ?? 1);
console.log(it.marketHashName, '->', `$${(v / 100).toFixed(2)}`);
}
Prices are always integer cents with an explicit currency, so you never guess units or fight
floating-point rounding.
Step 4 - Handle empty and private inventories
Two cases worth handling cleanly. An inventory that's reachable but holds nothing returns a normal 200
with status: "empty" and items: []. A private inventory (or profile) returns
403 inventory_private - surface a friendly “set your inventory to public” message there.
if (res.status === 403) return showPrivateNotice();
if (inv.status === 'empty') return showEmptyNotice();
Tips for production
- Lean on the cache. Results are cached ~24h per inventory, so repeat lookups are instant and
count as a normal request. Need a live refresh? Add
?fresh=1(bills one extra request). - Show the owner. The response includes the Steam
profile(persona name, avatar, profile URL) resolved in the same lookup - no extra call needed for a header. - Pick the right basis.
steamPriceis the familiar Steam number;realAvg(with?markets=1) tracks what skins actually trade for across marketplaces.
That's it
A working CS2 inventory calculator is one request and one field. Grab a key, or dig into the inventory endpoint reference for float, pattern, Doppler phase, blue-gem tier and the full price breakdown.