Skip to content

Instantly share code, notes, and snippets.

@IggsGrey
Last active December 10, 2022 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IggsGrey/7faef598e77cfc0609682ad9eb0cb66a to your computer and use it in GitHub Desktop.
Save IggsGrey/7faef598e77cfc0609682ad9eb0cb66a to your computer and use it in GitHub Desktop.
Determining the prices of a user's steam inventory using the backpack.tf API
<?php
namespace Mellarchy\SteamInventory\Enums;
class ItemQuality {
public function __construct()
{
}
public static function qualities() {
return [
"Normal" => [
"id" => 0,
"color" => "#B2B2B2",
],
"Stock" => [
"id" => 0,
"color" => "#B2B2B2",
],
"Genuine" => [
"id" => 1,
"color" => "#4D7455",
],
"rarity1" => [
"id" => 1,
"color" => "#4D7455",
],
"Vintage" => [
"id" => 3,
"color" => "#476291",
],
"Rarity3" => [
"id" => 4,
"color" => "#70550F",
],
"Unusual" => [
"id" => 5,
"color" => "#8650AC",
],
"rarity4" => [
"id" => 5,
"color" => "#8650AC",
],
"Unique" => [
"id" => 6,
"color" => "#FFD700",
],
"Community" => [
"id" => 7,
"color" => "#70B04A",
],
"Valve" => [
"id" => 8,
"color" => "#A50F79",
],
"developer" => [
"id" => 8,
"color" => "#A50F79",
],
"Self-Made" => [
"id" => 9,
"color" => "#70B04A",
],
"selfmade" => [
"id" => 9,
"color" => "#70B04A",
],
"Customized" => [
"id" => 10,
"color" => "#8D834B",
],
"Strange" => [
"id" => 11,
"color" => "#CF6A32",
],
"Completed" => [
"id" => 12,
"color" => "#8650AC",
],
"Haunted" => [
"id" => 13,
"color" => "#38F3AB",
],
"Collector's" => [
"id" => 14,
"color" => "#AA0000",
],
"collectors" => [
"id" => 14,
"color" => "#AA0000",
],
"paintkitweapon" => [
"id" => 15,
"color" => "#FAFAFA",
],
"Decorated" => [
"id" => 15,
"color" => "#FAFAFA",
],
"Decorated Weapon" => [
"id" => 15,
"color" => "#FAFAFA",
],
];
}
public static function effects() {
return [
// Unusual effect IDs and their matching name
4 => 'Community Sparkle',
5 => 'Holy Glow',
6 => 'Green Confetti',
7 => 'Purple Confetti',
8 => 'Haunted Ghosts',
9 => 'Green Energy',
10 => 'Purple Energy',
11 => 'Circling TF Logo',
12 => 'Massed Flies',
13 => 'Burning Flames',
14 => 'Scorching Flames',
15 => 'Searing Plasma',
16 => 'Vivid Plasma',
17 => 'Sunbeams',
18 => 'Circling Peace Sign',
19 => 'Circling Heart',
20 => 'Map Stamps',
29 => 'Stormy Storm',
30 => 'Blizzardy Storm',
31 => 'Nuts n\' Bolts',
32 => 'Orbiting Planets',
33 => 'Orbiting Fire',
34 => 'Bubbling',
35 => 'Smoking',
36 => 'Steaming',
37 => 'Flaming Lantern',
38 => 'Cloudy Moon',
39 => 'Cauldron Bubbles',
40 => 'Eerie Orbiting Fire',
43 => 'Knifestorm',
44 => 'Misty Skull',
45 => 'Harvest Moon',
46 => 'It\'s A Secret To Everybody',
47 => 'Stormy 13th Hour',
56 => 'Kill-a-Watt',
57 => 'Terror-Watt',
58 => 'Cloud 9',
59 => 'Aces High',
60 => 'Dead Presidents',
61 => 'Miami Nights',
62 => 'Disco Beat Down',
63 => 'Phosphorous',
64 => 'Sulphurous',
65 => 'Memory Leak',
66 => 'Overclocked',
67 => 'Electrostatic',
68 => 'Power Surge',
69 => 'Anti-Freeze',
70 => 'Time Warp',
71 => 'Green Black Hole',
72 => 'Roboactive',
73 => 'Arcana',
74 => 'Spellbound',
75 => 'Chiroptera Venenata',
76 => 'Poisoned Shadows',
77 => 'Something Burning This Way Comes',
78 => 'Hellfire',
79 => 'Darkblaze',
80 =>' Demonflame',
81 => 'Bonzo The All-Gnawing',
82 => 'Amaranthine',
83 => 'Stare From Beyond',
84 => 'The Ooze',
85 => 'Ghastly Ghosts Jr',
86 => 'Haunted Phantasm Jr',
87 => 'Frostbite',
88 => 'Molten Mallard',
89 => 'Morning Glory',
90 => 'Death at Dusk',
91 => 'Abduction',
92 => 'Atomic',
93 => 'Subatomic',
94 => 'Electric Hat Protector',
95 => 'Magnetic Hat Protector',
96 => 'Voltaic Hat Protector',
97 => 'Galactic Codex',
98 => 'Ancient Codex',
99 => 'Nebula',
100 => 'Death by Disco',
101 => 'It\'s a mystery to everyone',
102 => 'It\'s a puzzle to me',
103 => 'Ether Trail',
104 => 'Nether Trail',
105 => 'Ancient Eldritch',
106 => 'Eldritch Flame',
108 => 'Tesla Coil',
107 => 'Neutron Star',
109 => 'Starstorm Insomnia',
110 => 'Starstorm Slumber',
111 => 'Brain Drain',
112 => 'Open Mind',
113 => 'Head of Steam',
114 => 'Galactic Gateway',
115 => 'The Eldritch Opening',
116 => 'The Dark Doorway',
117 => 'Ring of Fire',
118 => 'Vicious Circle',
119 => 'White Lightning',
120 => 'Omniscient Orb',
121 => 'Clairvoyance',
122 => 'Fifth Dimension',
123 => 'Vicious Vortex',
124 => 'Menacing Miasma',
125 => 'Abyssal Aura',
126 => 'Wicked Wood',
127 => 'Ghastly Grove',
128 => 'Mystical Medley',
129 => 'Ethereal Essence',
130 => 'Twisted Radiance',
131 => 'Violet Vortex',
132 => 'Verdant Vortex',
133 => 'Valiant Vortex',
134 => 'Sparkling Lights',
135 => 'Frozen Icefall',
136 => 'Fragmented Gluons',
137 => 'Fragmented Quarks',
138 => 'Fragmented Photons',
139 => 'Defragmenting Reality',
141 => 'Fragmenting Reality',
142 => 'Refragmenting Reality',
143 => 'Snowfallen',
144 => 'Snowblinded',
145 => 'Pyroland Daydream',
147 => 'Verdatica',
148 => 'Aromatica',
149 => 'Chromatica',
150 => 'Prismatica',
151 => 'Bee Swarm',
152 => 'Frisky Fireflies',
153 => 'Smoldering Spirits',
154 => 'Wandering Wisps',
155 => 'Kaleidoscope',
156 => 'Green Giggler',
157 => 'Laugh-O-Lantern',
158 => 'Plum Prankster',
159 => 'Pyroland Nightmare',
160 => 'Gravelly Ghoul',
161 => 'Vexed Volcanics',
162 => 'Gourdian Angel',
163 => 'Pumpkin Party',
164 => 'Frozen Fractals',
165 => 'Lavender Landfall',
166 => 'Special Snowfall',
167 => 'Divine Desire',
168 => 'Distant Dream',
169 => 'Violent Wintertide',
170 => 'Blighted Snowstorm',
171 => 'Pale Nimbus',
172 => 'Genus Plasmos',
173 => 'Serenus Lumen',
174 => 'Ventum Maris',
175 => 'Mirthful Mistletoe',
177 => 'Resonation',
178 => 'Aggradation',
179 => 'Lucidation',
180 => 'Stunning',
181 => 'Ardentum Saturnalis',
182 => 'Fragrancium Elementalis',
183 => 'Reverium Irregularis',
185 => 'Perennial Petals',
186 => 'Flavorsome Sunset',
187 => 'Raspberry Bloom',
188 => 'Iridescence',
189 => 'Tempered Thorns',
190 => 'Devilish Diablo',
191 => 'Severed Serration',
192 => 'Shrieking Shades',
193 => 'Restless Wraiths',
194 => 'Restless Wraiths',
195 => 'Infernal Wraith',
196 => 'Phantom Crown',
197 => 'Ancient Specter',
198 => 'Viridescent Peeper',
199 => 'Eyes of Molten',
200 => 'Ominous Stare',
201 => 'Pumpkin Moon',
202 => 'Frantic Spooker',
203 => 'Frightened Poltergeist',
204 => 'Energetic Haunter',
205 => 'Smissmas Tree',
206 => 'Hospitable Festivity',
207 => 'Condescending Embrace',
208 => 'Condescending Embrace',
209 => 'Sparkling Spruce',
210 => 'Glittering Juniper',
211 => 'Prismatic Pine',
212 => 'Spiraling Lights',
213 => 'Twisting Lights',
214 => 'Stardust Pathway',
215 => 'Flurry Rush',
216 => 'Spark of Smissmas',
217 => 'Spark of Smissmas',
218 => 'Polar Forecast',
219 => 'Shining Stag',
220 => 'Holiday Horns',
221 => 'Ardent Antlers',
222 => 'Ardent Antlers',
223 => 'Festive Lights',
224 => 'Crustacean Sensation',
225 => 'Crustacean Sensation',
226 => 'Frosted Decadence',
227 => 'Frosted Decadence',
228 => 'Sprinkled Delights',
229 => 'Terrestrial Favor',
230 => 'Tropical Thrill',
231 => 'Flourishing Passion',
232 => 'Dazzling Fireworks',
233 => 'Blazing Fireworks',
234 => 'Shimmering Fireworks',
235 => 'Twinkling Fireworks',
236 => 'Sparkling Fireworks',
237 => 'Glowing Fireworks',
238 => 'Glimmering Fireworks',
239 => 'Flying Lights',
240 => 'Flying Lights',
241 => 'Limelight',
242 => 'Shining Star',
243 => 'Cold Cosmos',
244 => 'Refracting Fractals',
245 => 'Startrance',
246 => 'Startrance',
247 => 'Starlush',
248 => 'Starfire',
249 => 'Stardust',
250 => 'Contagious Eruption',
251 => 'Daydream Eruption',
252 => 'Volcanic Eruption',
253 => 'Divine Sunlight',
254 => 'Audiophile',
255 => 'Soundwave',
256 => 'Synesthesia',
257 => 'Haunted Kraken',
258 => 'Eerie Kraken',
259 => 'Soulful Slice',
260 => 'Horsemann\'s Hack',
261 => 'Haunted Forever!',
262 => 'Haunted Forever!',
263 => 'Forever And Forever!',
264 => 'Cursed Forever!',
265 => 'Moth Plague',
266 => 'Malevolent Monoculi',
267 => 'Haunted Wick',
268 => 'Haunted Wick',
269 => 'Wicked Wick',
270 => 'Spectral Wick',
701 => 'Hot',
702 => 'Isotope',
703 => 'Cool',
704 => 'Energy Orb',
3001 => 'Showstopper',
3002 => 'Showstopper',
3003 => 'Holy Grail',
3004 => '\'72',
3005 => 'Fountain of Delight',
3006 => 'Screaming Tiger',
3007 => 'Skill Gotten Gains',
3008 => 'Midnight Whirlwind',
3009 => 'Silver Cyclone',
3010 => 'Mega Strike',
3011 => 'Haunted Phantasm',
3012 => 'Ghastly Ghosts',
3013 => 'Hellish Inferno',
3014 => 'Spectral Swirl',
3015 => 'Infernal Flames',
3016 => 'Infernal Smoke',
3017 => 'Acidic Bubbles of Envy',
3018 => 'Flammable Bubbles of Attraction',
3019 => 'Poisonous Bubbles of Regret',
3020 => 'Roaring Rockets',
3021 => 'Spooky Night',
3022 => 'Ominous Night',
3023 => 'Bewitched',
3024 => 'Accursed',
3025 => 'Enchanted',
3026 => 'Static Mist',
3027 => 'Eerie Lightning',
3028 => 'Terrifying Thunder',
3029 => 'Jarate Shock',
3030 => 'Nether Void',
3031 => 'Good-Hearted Goodies',
3032 => 'Wintery Wisp',
3033 => 'Arctic Aurora',
3034 => 'Winter Spirit',
3035 => 'Festive Spirit',
3036 => 'Magical Spirit',
3037 => 'Spectral Escort',
3038 => 'Astral Presence',
3039 => 'Arcane Assistance',
3040 => 'Arcane Assistance',
3041 => 'Emerald Allurement',
3042 => 'Pyrophoric Personality',
3043 => 'Spellbound Aspect',
3044 => 'Static Shock',
3045 => 'Veno Shock',
3046 => 'Toxic Terrors',
3047 => 'Arachnid Assault',
3048 => 'Creepy Crawlies',
3049 => 'Delightful Star',
3050 => 'Frosted Star',
3051 => 'Apotheosis',
3052 => 'Ascension',
3053 => 'Reindoonicorn Rancher',
3054 => 'Reindoonicorn Rancher',
3055 => 'Twinkling Lights',
3056 => 'Shimmering Lights',
3059 => 'Spectral Shackles',
3060 => 'Cursed Confinement',
3061 => 'Cavalier de Carte',
3062 => 'Cavalier de Carte',
3063 => 'Hollow Flourish',
3064 => 'Magic Shuffle',
3065 => 'Vigorous Pulse',
3066 => 'Thundering Spirit',
3067 => 'Galvanic Defiance',
3068 => 'Wispy Halos',
3069 => 'Nether Wisps',
3070 => 'Aurora Borealis',
3071 => 'Aurora Australis',
3072 => 'Aurora Polaris',
3073 => 'Amethyst Winds',
3074 => 'Golden Gusts',
3075 => 'Smissmas Swirls',
3076 => 'Smissmas Swirls',
3077 => 'Minty Cypress',
3078 => 'Pristine Pine',
3079 => 'Sparkly Spruce',
3080 => 'Sparkly Spruce',
3081 => 'Festive Fever',
3082 => 'Festive Fever',
3083 => 'Golden Glimmer',
3084 => 'Frosty Silver',
3085 => 'Glamorous Dazzle',
3086 => 'Glamorous Dazzle',
3087 => 'Sublime Snowstorm',
3088 => 'Marigold Ritual',
3089 => 'Marigold Ritual',
3090 => 'Pungent Poison',
3091 => 'Blazed Brew',
3092 => 'Mysterious Mixture',
3093 => 'Linguistic Deviation',
3094 => 'Aurelian Seal',
3095 => 'Runic Imprisonment',
3096 => 'Runic Imprisonment',
3097 => 'Prismatic Haze',
3098 => 'Rising Ritual',
3099 => 'Rising Ritual',
3100 => 'Bloody Grip',
3101 => 'Bloody Grip',
3102 => 'Toxic Grip',
3103 => 'Infernal Grip',
3104 => 'Death Grip',
// Unusual effects names and their matching ID
'Community Sparkle' => 4,
'Holy Glow' => 5,
'Green Confetti' => 6,
'Purple Confetti' => 7,
'Haunted Ghosts' => 8,
'Green Energy' => 9,
'Purple Energy' => 10,
'Circling TF Logo' => 11,
'Massed Flies' => 12,
'Burning Flames' => 13,
'Scorching Flames' => 14,
'Searing Plasma' => 15,
'Vivid Plasma' => 16,
'Sunbeams' => 17,
'Circling Peace Sign' => 18,
'Circling Heart' => 19,
'Map Stamps' => 20,
'Stormy Storm' => 29,
'Blizzardy Storm' => 30,
'Nuts n\' Bolts' => 31,
'Orbiting Planets' => 32,
'Orbiting Fire' => 33,
'Bubbling' => 34,
'Smoking' => 35,
'Steaming' => 36,
'Flaming Lantern' => 37,
'Cloudy Moon' => 38,
'Cauldron Bubbles' => 39,
'Eerie Orbiting Fire' => 40,
'Knifestorm' => 43,
'Misty Skull' => 44,
'Harvest Moon' => 45,
'It\'s A Secret To Everybody' => 46,
'Stormy 13th Hour' => 47,
'Kill-a-Watt' => 56,
'Terror-Watt' => 57,
'Cloud 9' => 58,
'Aces High' => 59,
'Dead Presidents' => 60,
'Miami Nights' => 61,
'Disco Beat Down' => 62,
'Phosphorous' => 63,
'Sulphurous' => 64,
'Memory Leak' => 65,
'Overclocked' => 66,
'Electrostatic' => 67,
'Power Surge' => 68,
'Anti-Freeze' => 69,
'Time Warp' => 70,
'Green Black Hole' => 71,
'Roboactive' => 72,
'Arcana' => 73,
'Spellbound' => 74,
'Chiroptera Venenata' => 75,
'Poisoned Shadows' => 76,
'Something Burning This Way Comes' => 77,
'Hellfire' => 78,
'Darkblaze' => 79,
'Demonflame' => 80,
'Bonzo The All-Gnawing' => 81,
'Amaranthine' => 82,
'Stare From Beyond' => 83,
'The Ooze' => 84,
'Ghastly Ghosts Jr' => 85,
'Haunted Phantasm Jr' => 86,
'Frostbite' => 87,
'Molten Mallard' => 88,
'Morning Glory' => 89,
'Death at Dusk' => 90,
'Abduction' => 91,
'Atomic' => 92,
'Subatomic' => 93,
'Electric Hat Protector' => 94,
'Magnetic Hat Protector' => 95,
'Voltaic Hat Protector' => 96,
'Galactic Codex' => 97,
'Ancient Codex' => 98,
'Nebula' => 99,
'Death by Disco' => 100,
'It\'s a mystery to everyone' => 101,
'It\'s a puzzle to me' => 102,
'Ether Trail' => 103,
'Nether Trail' => 104,
'Ancient Eldritch' => 105,
'Eldritch Flame' => 106,
'Tesla Coil' => 108,
'Neutron Star' => 107,
'Starstorm Insomnia' => 109,
'Starstorm Slumber' => 110,
'Brain Drain' => 111,
'Open Mind' => 112,
'Head of Steam' => 113,
'Galactic Gateway' => 114,
'The Eldritch Opening' => 115,
'The Dark Doorway' => 116,
'Ring of Fire' => 117,
'Vicious Circle' => 118,
'White Lightning' => 119,
'Omniscient Orb' => 120,
'Clairvoyance' => 121,
'Fifth Dimension' => 122,
'Vicious Vortex' => 123,
'Menacing Miasma' => 124,
'Abyssal Aura' => 125,
'Wicked Wood' => 126,
'Ghastly Grove' => 127,
'Mystical Medley' => 128,
'Ethereal Essence' => 129,
'Twisted Radiance' => 130,
'Violet Vortex' => 131,
'Verdant Vortex' => 132,
'Valiant Vortex' => 133,
'Sparkling Lights' => 134,
'Frozen Icefall' => 135,
'Fragmented Gluons' => 136,
'Fragmented Quarks' => 137,
'Fragmented Photons' => 138,
'Defragmenting Reality' => 139,
'Fragmenting Reality' => 141,
'Refragmenting Reality' => 142,
'Snowfallen' => 143,
'Snowblinded' => 144,
'Pyroland Daydream' => 145,
'Verdatica' => 147,
'Aromatica' => 148,
'Chromatica' => 149,
'Prismatica' => 150,
'Bee Swarm' => 151,
'Frisky Fireflies' => 152,
'Smoldering Spirits' => 153,
'Wandering Wisps' => 154,
'Kaleidoscope' => 155,
'Green Giggler' => 156,
'Laugh-O-Lantern' => 157,
'Plum Prankster' => 158,
'Pyroland Nightmare' => 159,
'Gravelly Ghoul' => 160,
'Vexed Volcanics' => 161,
'Gourdian Angel' => 162,
'Pumpkin Party' => 163,
'Frozen Fractals' => 164,
'Lavender Landfall' => 165,
'Special Snowfall' => 166,
'Divine Desire' => 167,
'Distant Dream' => 168,
'Violent Wintertide' => 169,
'Blighted Snowstorm' => 170,
'Pale Nimbus' => 171,
'Genus Plasmos' => 172,
'Serenus Lumen' => 173,
'Ventum Maris' => 174,
'Mirthful Mistletoe' => 175,
'Resonation' => 177,
'Aggradation' => 178,
'Lucidation' => 179,
'Stunning' => 180,
'Ardentum Saturnalis' => 181,
'Fragrancium Elementalis' => 182,
'Reverium Irregularis' => 183,
'Perennial Petals' => 185,
'Flavorsome Sunset' => 186,
'Raspberry Bloom' => 187,
'Iridescence' => 188,
'Tempered Thorns' => 189,
'Devilish Diablo' => 190,
'Severed Serration' => 191,
'Shrieking Shades' => 192,
'Restless Wraiths' => [193, 194],
'Infernal Wraith' => 195,
'Phantom Crown' => 196,
'Ancient Specter' => 197,
'Viridescent Peeper' => 198,
'Eyes of Molten' => 199,
'Ominous Stare' => 200,
'Pumpkin Moon' => 201,
'Frantic Spooker' => 202,
'Frightened Poltergeist' => 203,
'Energetic Haunter' => 204,
'Smissmas Tree' => 205,
'Hospitable Festivity' => 206,
'Condescending Embrace' => [207, 208],
'Sparkling Spruce' => 209,
'Glittering Juniper' => 210,
'Prismatic Pine' => 211,
'Spiraling Lights' => 212,
'Twisting Lights' => 213,
'Stardust Pathway' => 214,
'Flurry Rush' => 215,
'Spark of Smissmas' => [216, 217],
'Polar Forecast' => 218,
'Shining Stag' => 219,
'Holiday Horns' => 220,
'Ardent Antlers' => [221, 222],
'Festive Lights' => 223,
'Crustacean Sensation' => [224, 225],
'Frosted Decadence' => [226, 227],
'Sprinkled Delights' => 228,
'Terrestrial Favor' => 229,
'Tropical Thrill' => 230,
'Flourishing Passion' => 231,
'Dazzling Fireworks' => 232,
'Blazing Fireworks' => 233,
'Shimmering Fireworks' => 234,
'Twinkling Fireworks' => 235,
'Sparkling Fireworks' => 236,
'Glowing Fireworks' => 237,
'Glimmering Fireworks' => 238,
'Flying Lights' => [239, 240],
'Limelight' => 241,
'Shining Star' => 242,
'Cold Cosmos' => 243,
'Refracting Fractals' => 244,
'Startrance' => [245, 246],
'Starlush' => 247,
'Starfire' => 248,
'Stardust' => 249,
'Contagious Eruption' => 250,
'Daydream Eruption' => 251,
'Volcanic Eruption' => 252,
'Divine Sunlight' => 253,
'Audiophile' => 254,
'Soundwave' => 255,
'Synesthesia' => 256,
'Haunted Kraken' => 257,
'Eerie Kraken' => 258,
'Soulful Slice' => 259,
'Horsemann\'s Hack' => 260,
'Haunted Forever!' => [261, 262],
'Forever And Forever!' => 263,
'Cursed Forever!' => 264,
'Moth Plague' => 265,
'Malevolent Monoculi' => 266,
'Haunted Wick' => [267, 268],
'Wicked Wick' => 269,
'Spectral Wick' => 270,
'Hot' => 701,
'Isotope' => 702,
'Cool' => 703,
'Energy Orb' => 704,
'Showstopper' => [3001, 3002],
'Holy Grail' => 3003,
'\'72' => 3004,
'Fountain of Delight' => 3005,
'Screaming Tiger' => 3006,
'Skill Gotten Gains' => 3007,
'Midnight Whirlwind' => 3008,
'Silver Cyclone' => 3009,
'Mega Strike' => 3010,
'Haunted Phantasm' => 3011,
'Ghastly Ghosts' => 3012,
'Hellish Inferno' => 3013,
'Spectral Swirl' => 3014,
'Infernal Flames' => 3015,
'Infernal Smoke' => 3016,
'Acidic Bubbles of Envy' => 3017,
'Flammable Bubbles of Attraction' => 3018,
'Poisonous Bubbles of Regret' => 3019,
'Roaring Rockets' => 3020,
'Spooky Night' => 3021,
'Ominous Night' => 3022,
'Bewitched' => 3023,
'Accursed' => 3024,
'Enchanted' => 3025,
'Static Mist' => 3026,
'Eerie Lightning' => 3027,
'Terrifying Thunder' => 3028,
'Jarate Shock' => 3029,
'Nether Void' => 3030,
'Good-Hearted Goodies' => 3031,
'Wintery Wisp' => 3032,
'Arctic Aurora' => 3033,
'Winter Spirit' => 3034,
'Festive Spirit' => 3035,
'Magical Spirit' => 3036,
'Spectral Escort' => 3037,
'Astral Presence' => 3038,
'Arcane Assistance' => [3039, 3040],
'Emerald Allurement' => 3041,
'Pyrophoric Personality' => 3042,
'Spellbound Aspect' => 3043,
'Static Shock' => 3044,
'Veno Shock' => 3045,
'Toxic Terrors' => 3046,
'Arachnid Assault' => 3047,
'Creepy Crawlies' => 3048,
'Delightful Star' => 3049,
'Frosted Star' => 3050,
'Apotheosis' => 3051,
'Ascension' => 3052,
'Reindoonicorn Rancher' => [3053, 3054],
'Twinkling Lights' => 3055,
'Shimmering Lights' => 3056,
'Spectral Shackles' => 3059,
'Cursed Confinement' => 3060,
'Cavalier de Carte' => [3061, 3062],
'Hollow Flourish' => 3063,
'Magic Shuffle' => 3064,
'Vigorous Pulse' => 3065,
'Thundering Spirit' => 3066,
'Galvanic Defiance' => 3067,
'Wispy Halos' => 3068,
'Nether Wisps' => 3069,
'Aurora Borealis' => 3070,
'Aurora Australis' => 3071,
'Aurora Polaris' => 3072,
'Amethyst Winds' => 3073,
'Golden Gusts' => 3074,
'Smissmas Swirls' => [3075, 3076],
'Minty Cypress' => 3077,
'Pristine Pine' => 3078,
'Sparkly Spruce' => [3079, 3080],
'Festive Fever' => [3081, 3082],
'Golden Glimmer' => 3083,
'Frosty Silver' => 3084,
'Glamorous Dazzle' => [3085, 3086],
'Sublime Snowstorm' => 3087,
'Marigold Ritual' => [3088, 3089],
'Pungent Poison' => 3090,
'Blazed Brew' => 3091,
'Mysterious Mixture' => 3092,
'Linguistic Deviation' => 3093,
'Aurelian Seal' => 3094,
'Runic Imprisonment' => [3095, 3096],
'Prismatic Haze' => 3097,
'Rising Ritual' => [3098, 3099],
'Bloody Grip' => [3100, 3101],
'Toxic Grip' => 3102,
'Infernal Grip' => 3103,
'Death Grip' => 3104
];
}
}
<?php
namespace Mellarchy\SteamInventory;
use GuzzleHttp\Client;
use Mellarchy\SteamInventory\Enums\ItemQuality;
/**
*
*/
class Steam
{
function __construct()
{
// global definitions
define('STEAM_API_KEY', 'xxxxxx');
define('BACKPACK_API_KEY', 'xxxxxx');
$this->client = new Client;
}
public function getInventory($params) {
if(!array_key_exists('user_steam_id', $params) || !$params['user_steam_id']) {
throw new \Exception("The target user's Steam ID was not specified", 1);
}
$user_steam_id = $params['user_steam_id'];
$per_page_count = array_key_exists('per_page_count', $params) ? $params['per_page_count'] : 5000;
$start_assetid = array_key_exists('start_assetid', $params) ? $params['start_assetid'] : null;
$url = "https://steamcommunity.com/inventory/".$user_steam_id."/440/2?key=".STEAM_API_KEY."&l=english&count=$per_page_count";
if($start_assetid) {
$url .= "&start_assetid=$start_assetid";
}
$res = $this->client->get($url, [
"verify" => false,
]);
$body = json_decode($res->getBody());
// get assets from steam inventory API response
$assets = $body->assets;
// get descriptions from steam inventory API response
$descriptions = $body->descriptions;
// get backpack.tf item and prices
$res = $this->client->get("https://backpack.tf/api/IGetPrices/v4?key=".BACKPACK_API_KEY."&raw=1", [
"verify" => false,
'headers' => [
"Accept" => "*/*",
"Content-Type" => "application/json",
]
]);
$backpackPrices = json_decode($res->getBody());
// get base raw USD value of the items
$usd_value = $backpackPrices
->response
->raw_usd_value;
$items = collect($assets)
// filter items that exist in backpak.tf items
// and are tradable
->filter(function($item) use ($descriptions, $backpackPrices) {
// find the description associated with the current item
$description = collect($descriptions)
->filter(function($desc) use ($item) {
return $desc->classid == $item->classid;
})
->first();
return
// item is tradable
$description->tradable
&&
// item name or market_name exists in backpak.tf items
collect(
$backpackPrices
->response
->items
)
->first(function($bp, $key) use ($description) {
return $key == $description->name || $key == $description->market_name;
});
})
// add each item's price & merge it's description
->map(function($item) use ($usd_value, $descriptions, $backpackPrices) {
$description = collect($descriptions)
->filter(function($desc) use ($item) {
return $desc->classid == $item->classid;
})
->first();
// determine the quality of an item
$item_quality_id = $this->getItemQualityID($item, $description);
$tradable_price_schema = collect(
$backpackPrices
->response
->items
)
->first(function($bp, $key) use ($description) {
return $key == $description->market_name;
})
->prices
->$item_quality_id
->Tradable;
// determine if item is Craftable or not
$craft_key = property_exists($tradable_price_schema, 'Craftable') ? "Craftable" : "Non-Craftable";
// get price of item in steam currency
$raw_price = collect($tradable_price_schema->$craft_key)
->sortBy('last_update')
->last()
->value_raw;
// set item to price equal to
// conversion of steam currency to dollars
// round to 4dp
$item->price = round($raw_price * $usd_value, 4);
// TODO: Work on how to determine particle images
$item->particle_image = "https://backpack.tf/images/440/particles/10_94x94.png";
if(!str_contains($description->icon_url, "http")) {
$description->icon_url = "https://steamcommunity-a.akamaihd.net/economy/image/$description->icon_url";
}
// finally, combine the asset and description items
return array_merge((array) $item, (array) $description);
})
// sort in descending order of item with highest price
->sortByDesc('price');
return $items;
}
public function getItemQualityID($item, $description) {
$quality = collect(ItemQuality::qualities())
->first(function($q) use ($description) {
return $q["color"] == $description->name_color;
});
if ($quality) {
return $quality["id"];
} else {
$item_quality = collect(
$description
->tags
)
->first(function($tag) {
return strtolower($tag->category) == "quality";
})
->localized_tag_name;
return ItemQuality::qualities()[$item_quality]["id"];
}
return null;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment