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

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&currency=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 } }
Steam value vs. real value. Steam caps market listings at ~$1,800, so an item worth more (a Dragon Lore, a top-tier knife) is counted at the cap - 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

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.

Get your API key