@@ -73,6 +73,42 @@ decoded = deserialize(hex_str) # round-trip
7373
7474---
7575
76+ ## Gen codes
77+
78+ Generate a Steam inspect URL from item parameters (defindex, paintindex, paintseed, paintwear):
79+
80+ ``` python
81+ from cs2_inspect import generate, to_gen_code, parse_gen_code, ItemPreviewData, Sticker
82+
83+ # Generate a Steam inspect URL from item parameters
84+ url = generate(7 , 474 , 306 , 0.22540508 )
85+ # steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20...
86+
87+ # Convert ItemPreviewData to a gen code string
88+ item = ItemPreviewData(defindex = 7 , paintindex = 474 , paintseed = 306 , paintwear = 0.22540508 )
89+ code = to_gen_code(item) # "!gen 7 474 306 0.22540508"
90+ code = to_gen_code(item, " !g" ) # "!g 7 474 306 0.22540508"
91+
92+ # With stickers (slot index 0–4, padded to 5 pairs) and keychain
93+ item2 = ItemPreviewData(
94+ defindex = 7 , paintindex = 941 , paintseed = 2 , paintwear = 0.22540508 ,
95+ stickers = [Sticker(slot = 2 , sticker_id = 7203 , wear = 0.0 )],
96+ keychains = [Sticker(slot = 0 , sticker_id = 36 , wear = 0.0 )],
97+ )
98+ to_gen_code(item2, " !g" )
99+ # "!g 7 941 2 0.22540508 0 0 0 0 7203 0 0 0 0 0 36 0"
100+
101+ # Parse a gen code back to ItemPreviewData
102+ item3 = parse_gen_code(" !gen 7 474 306 0.22540508" )
103+
104+ # Convert an existing inspect link directly to a gen code
105+ from cs2_inspect import gen_code_from_link
106+ code = gen_code_from_link(" steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20001A..." )
107+ # "!gen 7 474 306 0.22540508"
108+ ```
109+
110+ ---
111+
76112## Validation
77113
78114Use ` is_masked() ` and ` is_classic() ` to detect the link type without decoding it.
0 commit comments