cs2-inventory-resolver 0.4.19 → 0.4.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -8
- package/data/inventory.json +1 -1
- package/dist/types.d.ts +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,6 +8,16 @@ Resolve raw CS2 Game Coordinator (GC) items into human-readable names, images, a
|
|
|
8
8
|
npm install cs2-inventory-resolver
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
This package is ESM-only. Use `import`, or `await import()` from CommonJS.
|
|
12
|
+
|
|
13
|
+
## Where the input comes from
|
|
14
|
+
|
|
15
|
+
`resolveItem` takes a raw `CSOEconItem` as delivered by the CS2 Game Coordinator —
|
|
16
|
+
the shape you get from [`node-globaloffensive`](https://github.com/DoctorMcKay/node-globaloffensive)
|
|
17
|
+
(via [`steam-user`](https://github.com/DoctorMcKay/node-steam-user)) when reading an
|
|
18
|
+
inventory. This library does no networking of its own; it only turns those raw
|
|
19
|
+
items into readable data.
|
|
20
|
+
|
|
11
21
|
## Usage
|
|
12
22
|
|
|
13
23
|
### `resolveItem(gcItem)`
|
|
@@ -26,19 +36,36 @@ import { resolveItem } from 'cs2-inventory-resolver';
|
|
|
26
36
|
|
|
27
37
|
// Regular skin
|
|
28
38
|
resolveItem({ def_index: 7, paint_index: 282, paint_wear: 0.30 });
|
|
29
|
-
// => {
|
|
30
|
-
|
|
31
|
-
//
|
|
32
|
-
|
|
39
|
+
// => {
|
|
40
|
+
// name: "AK-47 | Redline (Field-Tested)",
|
|
41
|
+
// image: "https://community.akamai.steamstatic.com/economy/image/...",
|
|
42
|
+
// entity: "skin",
|
|
43
|
+
// rarity: { id: "rarity_legendary_weapon", name: "Classified", color: "#d32ce6" },
|
|
44
|
+
// marketable: true,
|
|
45
|
+
// status: "tradable",
|
|
46
|
+
// trade_hold_expires: null
|
|
47
|
+
// }
|
|
48
|
+
|
|
49
|
+
// StatTrak skin (attribute 80 present)
|
|
50
|
+
const statTrak = [{ def_index: 80, value_bytes: Buffer.from([1, 0, 0, 0]) }];
|
|
51
|
+
resolveItem({ def_index: 7, paint_index: 282, paint_wear: 0.30, attribute: statTrak });
|
|
33
52
|
// => { name: "StatTrak™ AK-47 | Redline (Field-Tested)", ... }
|
|
34
53
|
|
|
35
54
|
// StatTrak knife (quality 3 = ★ already in name)
|
|
36
|
-
resolveItem({ def_index: 507, paint_index: 38, quality: 3, paint_wear: 0.01, attribute:
|
|
37
|
-
// => { name: "★ StatTrak™ Karambit | Fade (Factory New)", ... }
|
|
55
|
+
resolveItem({ def_index: 507, paint_index: 38, quality: 3, paint_wear: 0.01, attribute: statTrak });
|
|
56
|
+
// => { name: "★ StatTrak™ Karambit | Fade (Factory New)", entity: "skin", ... }
|
|
38
57
|
|
|
39
58
|
// Non-skin item
|
|
40
|
-
resolveItem({ def_index:
|
|
41
|
-
// => {
|
|
59
|
+
resolveItem({ def_index: 1203 });
|
|
60
|
+
// => {
|
|
61
|
+
// name: "CS:GO Case Key",
|
|
62
|
+
// image: "https://community.akamai.steamstatic.com/economy/image/...",
|
|
63
|
+
// entity: "key",
|
|
64
|
+
// rarity: null,
|
|
65
|
+
// marketable: true,
|
|
66
|
+
// status: "tradable",
|
|
67
|
+
// trade_hold_expires: null
|
|
68
|
+
// }
|
|
42
69
|
```
|
|
43
70
|
|
|
44
71
|
Returns `null` if the item could not be identified.
|
|
@@ -77,6 +104,18 @@ Derived from attribute `312` (`trade_protected_escrow_date`). Items that are not
|
|
|
77
104
|
| `'market_listed'` | Listed on the Steam Community Market, kept in the inventory until it sells (attribute is `0`) | `null` |
|
|
78
105
|
| `'trade_hold'` | Under a trade-protection / escrow hold (attribute is a future timestamp) | ISO date |
|
|
79
106
|
|
|
107
|
+
```ts
|
|
108
|
+
const escrow = Buffer.alloc(4);
|
|
109
|
+
escrow.writeUInt32LE(Math.floor(new Date('2026-09-01T12:00:00Z').getTime() / 1000));
|
|
110
|
+
|
|
111
|
+
resolveItem({ def_index: 7, paint_index: 282, paint_wear: 0.30, attribute: [{ def_index: 312, value_bytes: escrow }] });
|
|
112
|
+
// => { ..., status: "trade_hold", trade_hold_expires: "2026-09-01T12:00:00.000Z" }
|
|
113
|
+
|
|
114
|
+
// An escrow date of 0 means the item is listed on the Market
|
|
115
|
+
resolveItem({ def_index: 7, paint_index: 282, paint_wear: 0.30, attribute: [{ def_index: 312, value_bytes: Buffer.alloc(4) }] });
|
|
116
|
+
// => { ..., status: "market_listed", trade_hold_expires: null }
|
|
117
|
+
```
|
|
118
|
+
|
|
80
119
|
### `getAttributeUint32(item, attrDefIndex)`
|
|
81
120
|
|
|
82
121
|
Reads a uint32 value from a GC item's raw `attribute[]` array.
|
|
@@ -89,3 +128,18 @@ if (musicIndex) {
|
|
|
89
128
|
console.log('Music kit ID:', musicIndex);
|
|
90
129
|
}
|
|
91
130
|
```
|
|
131
|
+
|
|
132
|
+
## Item data
|
|
133
|
+
|
|
134
|
+
Item names, images, rarities and marketability come from
|
|
135
|
+
[CSGO-API](https://github.com/ByMykel/CSGO-API) and ship with the package as
|
|
136
|
+
`data/inventory.json` — no network calls at runtime.
|
|
137
|
+
|
|
138
|
+
That file is refreshed daily by a scheduled workflow. When the upstream data
|
|
139
|
+
changes, a new **patch** release is published, so a `^0.4.0` dependency picks up
|
|
140
|
+
new skins, cases and stickers automatically. Each release lists what was added or
|
|
141
|
+
removed.
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
[MIT](LICENSE)
|