cs2-inventory-resolver 0.4.27 → 0.4.29
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/LICENSE +21 -21
- package/README.md +145 -145
- package/data/inventory.json +1 -1
- package/package.json +39 -39
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 ByMykel
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ByMykel
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
# cs2-inventory-resolver
|
|
2
|
-
|
|
3
|
-
Resolve raw CS2 Game Coordinator (GC) items into human-readable names, images, and categories.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install cs2-inventory-resolver
|
|
9
|
-
```
|
|
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
|
-
|
|
21
|
-
## Usage
|
|
22
|
-
|
|
23
|
-
### `resolveItem(gcItem)`
|
|
24
|
-
|
|
25
|
-
Takes a raw GC item and returns its name, image URL, entity type, rarity, and marketability.
|
|
26
|
-
|
|
27
|
-
For skins, the `name` is fully decorated with the appropriate prefix and wear:
|
|
28
|
-
|
|
29
|
-
- `StatTrak™` prefix (detected via attribute 80)
|
|
30
|
-
- `Souvenir` prefix (detected via attribute 140)
|
|
31
|
-
- `★` for knives/gloves (already included in the base name)
|
|
32
|
-
- Wear suffix based on `paint_wear` (e.g. `Factory New`, `Field-Tested`)
|
|
33
|
-
|
|
34
|
-
```ts
|
|
35
|
-
import { resolveItem } from 'cs2-inventory-resolver';
|
|
36
|
-
|
|
37
|
-
// Regular skin
|
|
38
|
-
resolveItem({ def_index: 7, paint_index: 282, paint_wear: 0.30 });
|
|
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 });
|
|
52
|
-
// => { name: "StatTrak™ AK-47 | Redline (Field-Tested)", ... }
|
|
53
|
-
|
|
54
|
-
// StatTrak knife (quality 3 = ★ already in name)
|
|
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", ... }
|
|
57
|
-
|
|
58
|
-
// Non-skin item
|
|
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
|
-
// }
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
Returns `null` if the item could not be identified.
|
|
72
|
-
|
|
73
|
-
#### Input (`GcItemInput`)
|
|
74
|
-
|
|
75
|
-
| Field | Type | Description |
|
|
76
|
-
|-------|------|-------------|
|
|
77
|
-
| `def_index` | `number` | Item definition index (required) |
|
|
78
|
-
| `paint_index` | `number?` | Paint/skin index |
|
|
79
|
-
| `quality` | `number?` | Item quality (`3` = ★ knife/glove) |
|
|
80
|
-
| `paint_wear` | `number?` | Wear float (`0.0`–`1.0`) |
|
|
81
|
-
| `stickers` | `{sticker_id?: number}[]?` | Sticker slots |
|
|
82
|
-
| `attribute` | `{def_index: number; value_bytes?: Buffer}[]?` | Raw attribute array |
|
|
83
|
-
|
|
84
|
-
#### Output (`ResolvedItemData`)
|
|
85
|
-
|
|
86
|
-
| Field | Type | Description |
|
|
87
|
-
|-------|------|-------------|
|
|
88
|
-
| `name` | `string` | Decorated item name |
|
|
89
|
-
| `image` | `string` | Image URL |
|
|
90
|
-
| `entity` | `ItemEntity` | Item type (`skin`, `crate`, `key`, `collectible`, etc.) |
|
|
91
|
-
| `rarity` | `{id, name, color} \| null` | Rarity info or `null` |
|
|
92
|
-
| `marketable` | `boolean` | Whether the item is marketable on Steam |
|
|
93
|
-
| `status` | `TradeStatus` | Trade state of this instance (see below) |
|
|
94
|
-
| `trade_hold_expires` | `string \| null` | ISO 8601 trade-hold expiry, or `null` |
|
|
95
|
-
|
|
96
|
-
#### Trade status (`TradeStatus`)
|
|
97
|
-
|
|
98
|
-
Derived from attribute `312` (`trade_protected_escrow_date`). Items that are not
|
|
99
|
-
`'tradable'` cannot be moved into or out of a storage unit.
|
|
100
|
-
|
|
101
|
-
| Value | Meaning | `trade_hold_expires` |
|
|
102
|
-
|-------|---------|--------------------|
|
|
103
|
-
| `'tradable'` | No hold — freely tradable and movable (attribute absent) | `null` |
|
|
104
|
-
| `'market_listed'` | Listed on the Steam Community Market, kept in the inventory until it sells (attribute is `0`) | `null` |
|
|
105
|
-
| `'trade_hold'` | Under a trade-protection / escrow hold (attribute is a future timestamp) | ISO date |
|
|
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
|
-
|
|
119
|
-
### `getAttributeUint32(item, attrDefIndex)`
|
|
120
|
-
|
|
121
|
-
Reads a uint32 value from a GC item's raw `attribute[]` array.
|
|
122
|
-
|
|
123
|
-
```ts
|
|
124
|
-
import { getAttributeUint32 } from 'cs2-inventory-resolver';
|
|
125
|
-
|
|
126
|
-
const musicIndex = getAttributeUint32(gcItem, 166);
|
|
127
|
-
if (musicIndex) {
|
|
128
|
-
console.log('Music kit ID:', musicIndex);
|
|
129
|
-
}
|
|
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)
|
|
1
|
+
# cs2-inventory-resolver
|
|
2
|
+
|
|
3
|
+
Resolve raw CS2 Game Coordinator (GC) items into human-readable names, images, and categories.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install cs2-inventory-resolver
|
|
9
|
+
```
|
|
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
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### `resolveItem(gcItem)`
|
|
24
|
+
|
|
25
|
+
Takes a raw GC item and returns its name, image URL, entity type, rarity, and marketability.
|
|
26
|
+
|
|
27
|
+
For skins, the `name` is fully decorated with the appropriate prefix and wear:
|
|
28
|
+
|
|
29
|
+
- `StatTrak™` prefix (detected via attribute 80)
|
|
30
|
+
- `Souvenir` prefix (detected via attribute 140)
|
|
31
|
+
- `★` for knives/gloves (already included in the base name)
|
|
32
|
+
- Wear suffix based on `paint_wear` (e.g. `Factory New`, `Field-Tested`)
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { resolveItem } from 'cs2-inventory-resolver';
|
|
36
|
+
|
|
37
|
+
// Regular skin
|
|
38
|
+
resolveItem({ def_index: 7, paint_index: 282, paint_wear: 0.30 });
|
|
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 });
|
|
52
|
+
// => { name: "StatTrak™ AK-47 | Redline (Field-Tested)", ... }
|
|
53
|
+
|
|
54
|
+
// StatTrak knife (quality 3 = ★ already in name)
|
|
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", ... }
|
|
57
|
+
|
|
58
|
+
// Non-skin item
|
|
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
|
+
// }
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Returns `null` if the item could not be identified.
|
|
72
|
+
|
|
73
|
+
#### Input (`GcItemInput`)
|
|
74
|
+
|
|
75
|
+
| Field | Type | Description |
|
|
76
|
+
|-------|------|-------------|
|
|
77
|
+
| `def_index` | `number` | Item definition index (required) |
|
|
78
|
+
| `paint_index` | `number?` | Paint/skin index |
|
|
79
|
+
| `quality` | `number?` | Item quality (`3` = ★ knife/glove) |
|
|
80
|
+
| `paint_wear` | `number?` | Wear float (`0.0`–`1.0`) |
|
|
81
|
+
| `stickers` | `{sticker_id?: number}[]?` | Sticker slots |
|
|
82
|
+
| `attribute` | `{def_index: number; value_bytes?: Buffer}[]?` | Raw attribute array |
|
|
83
|
+
|
|
84
|
+
#### Output (`ResolvedItemData`)
|
|
85
|
+
|
|
86
|
+
| Field | Type | Description |
|
|
87
|
+
|-------|------|-------------|
|
|
88
|
+
| `name` | `string` | Decorated item name |
|
|
89
|
+
| `image` | `string` | Image URL |
|
|
90
|
+
| `entity` | `ItemEntity` | Item type (`skin`, `crate`, `key`, `collectible`, etc.) |
|
|
91
|
+
| `rarity` | `{id, name, color} \| null` | Rarity info or `null` |
|
|
92
|
+
| `marketable` | `boolean` | Whether the item is marketable on Steam |
|
|
93
|
+
| `status` | `TradeStatus` | Trade state of this instance (see below) |
|
|
94
|
+
| `trade_hold_expires` | `string \| null` | ISO 8601 trade-hold expiry, or `null` |
|
|
95
|
+
|
|
96
|
+
#### Trade status (`TradeStatus`)
|
|
97
|
+
|
|
98
|
+
Derived from attribute `312` (`trade_protected_escrow_date`). Items that are not
|
|
99
|
+
`'tradable'` cannot be moved into or out of a storage unit.
|
|
100
|
+
|
|
101
|
+
| Value | Meaning | `trade_hold_expires` |
|
|
102
|
+
|-------|---------|--------------------|
|
|
103
|
+
| `'tradable'` | No hold — freely tradable and movable (attribute absent) | `null` |
|
|
104
|
+
| `'market_listed'` | Listed on the Steam Community Market, kept in the inventory until it sells (attribute is `0`) | `null` |
|
|
105
|
+
| `'trade_hold'` | Under a trade-protection / escrow hold (attribute is a future timestamp) | ISO date |
|
|
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
|
+
|
|
119
|
+
### `getAttributeUint32(item, attrDefIndex)`
|
|
120
|
+
|
|
121
|
+
Reads a uint32 value from a GC item's raw `attribute[]` array.
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
import { getAttributeUint32 } from 'cs2-inventory-resolver';
|
|
125
|
+
|
|
126
|
+
const musicIndex = getAttributeUint32(gcItem, 166);
|
|
127
|
+
if (musicIndex) {
|
|
128
|
+
console.log('Music kit ID:', musicIndex);
|
|
129
|
+
}
|
|
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)
|