npm.io
0.4.9 • Published yesterday

cs2-inventory-resolver

Licence
Version
0.4.9
Deps
0
Size
9.8 MB
Vulns
0
Weekly
562

cs2-inventory-resolver

Resolve raw CS2 Game Coordinator (GC) items into human-readable names, images, and categories.

Installation

npm install cs2-inventory-resolver

Usage

resolveItem(gcItem)

Takes a raw GC item and returns its name, image URL, entity type, rarity, and marketability.

For skins, the name is fully decorated with the appropriate prefix and wear:

  • StatTrak™ prefix (detected via attribute 80)
  • Souvenir prefix (detected via attribute 140)
  • for knives/gloves (already included in the base name)
  • Wear suffix based on paint_wear (e.g. Factory New, Field-Tested)
import { resolveItem } from 'cs2-inventory-resolver';

// Regular skin
resolveItem({ def_index: 7, paint_index: 282, paint_wear: 0.30 });
// => { name: "AK-47 | Redline (Field-Tested)", image: "https://...", entity: "skin", rarity: { id: "rarity_mythical_weapon", name: "Restricted", color: "#8847ff" }, marketable: true }

// StatTrak skin
resolveItem({ def_index: 7, paint_index: 282, paint_wear: 0.30, attribute: [{ def_index: 80, value_bytes: ... }] });
// => { name: "StatTrak™ AK-47 | Redline (Field-Tested)", ... }

// StatTrak knife (quality 3 = ★ already in name)
resolveItem({ def_index: 507, paint_index: 38, quality: 3, paint_wear: 0.01, attribute: [{ def_index: 80, value_bytes: ... }] });
// => { name: "★ StatTrak™ Karambit | Fade (Factory New)", ... }

// Non-skin item
resolveItem({ def_index: 1505 });
// => { name: "CS:GO Case Key", image: "https://...", entity: "key", rarity: null, marketable: true }

Returns null if the item could not be identified.

Input (GcItemInput)
Field Type Description
def_index number Item definition index (required)
paint_index number? Paint/skin index
quality number? Item quality (3 = ★ knife/glove)
paint_wear number? Wear float (0.01.0)
stickers {sticker_id?: number}[]? Sticker slots
attribute {def_index: number; value_bytes?: Buffer}[]? Raw attribute array
Output (ResolvedItemData)
Field Type Description
name string Decorated item name
image string Image URL
entity ItemEntity Item type (skin, crate, key, collectible, etc.)
rarity {id, name, color} | null Rarity info or null
marketable boolean Whether the item is marketable on Steam
status TradeStatus Trade state of this instance (see below)
trade_hold_expires string | null ISO 8601 trade-hold expiry, or null
Trade status (TradeStatus)

Derived from attribute 312 (trade_protected_escrow_date). Items that are not 'tradable' cannot be moved into or out of a storage unit.

Value Meaning trade_hold_expires
'tradable' No hold — freely tradable and movable (attribute absent) null
'market_listed' Listed on the Steam Community Market, kept in the inventory until it sells (attribute is 0) null
'trade_hold' Under a trade-protection / escrow hold (attribute is a future timestamp) ISO date
getAttributeUint32(item, attrDefIndex)

Reads a uint32 value from a GC item's raw attribute[] array.

import { getAttributeUint32 } from 'cs2-inventory-resolver';

const musicIndex = getAttributeUint32(gcItem, 166);
if (musicIndex) {
  console.log('Music kit ID:', musicIndex);
}

Keywords