Steam price tracker/alert

March 7, 2016 by Asbra — Leave a comment

There is a GitHub repo with the source code of this project.

As someone who likes to bargain for games, I wanted a simple way to get notified of price changes to the games I’m interested in. Steam has a built-in feature that emails you when there’s a sale on items in your wishlist, but I wanted something more.

What I ended up with is a script that sends me an email notification whenever the price drops (either normal reduction or on a sale) on one of the games in my wishlist and the games I follow.

This article will serve to explain the approach which I took to create this script, if you just want to look at the final thing, head on over to my GitHub repo.

Email sent looks like this:

Steam discount alert

Email notification sent by Steam price tracker script

Retrieve your Steam wishlist

First we grab the games from our Steam wishlist, in my case https://steamcommunity.com/id/novoc/wishlist, and use a regex to match out the games’ app IDs.

r = requests.get('https://steamcommunity.com/id/novoc/wishlist')
wishlist = re.findall(r'id="game_([0-9]+)"', r.text)

Scrape followed games list

Next we get the list of followed games in a similar manner, again matching out the app IDs with regex.

r = requests.get('https://steamcommunity.com/id/novoc/followedgames')
followed = re.findall(r'data-appid="([0-9]+)"', r.text)

Retrieve list of your Steam games

Finally we grab the list of games we already own, so we can avoid getting price notifications regarding those.

r = requests.get('https://steamcommunity.com/id/novoc/games/?tab=all')
owned = re.findall(r'"appid":([0-9]+),', r.text)

Get current price of a Steam game

Now we iterate through the list we’ve gathered, and get store information for each app ID we have. The GET variable cc is the country code of the country you want to get price information for.
The appdetails API endpoint gives us back JSON formatted data, easily parsed.

region = 'th'
url = 'https://store.steampowered.com/api/appdetails?appids=%s&cc=%s' % (appid, region)
r = requests.get(url)
j = r.json()

For example, here’s output of https://store.steampowered.com/api/appdetails?appids=248860&cc=th, Steam store details for the execellent game NEO Scavenger

{"248860":{"success":true,"data":{"type":"game","name":"NEO Scavenger","steam_appid":248860,"required_age":0,"is_free":false,"detailed_description":"NEO Scavenger is a game where you must survive in the wasteland long enough to figure out who you are. Each turn, you must decide where to go, how to scavenge for supplies, and how to deal with anything and anyone you encounter. And with each passing minute, the pit in your stomach grows, your dehydration worsens, your muscles tire, and your body temperature drops in the cold autumn air. Choose your starting abilities carefully, because they and your wit are the only tools you have in the apocalypse!<h2 class=\"bb_tag\">Features<\/h2>\r<ul class=\"bb_ul\">\r<li><strong>Unique Setting<\/strong> - Near-future, post-apocalyptic Michigan with local cryptids and folklore. And something else beneath the surface...\r<br><\/li><li><strong>Turn-Based Play<\/strong> - Take your time with each turn, and play at your own pace. Save and quit when you want, and resume later.\r<br><\/li><li><strong>Permadeath<\/strong> - If you die, that's it. NEO Scavenger is balanced around a single difficulty level: permadeath. Your save will be deleted if you die. So choose every action carefully!\r<br><\/li><li><strong>No Grinding<\/strong> - There is no XP in NEO Scavenger. No levelling-up. Instead, progress comes from learning how to play the game better, and using your strengths to your advantage.\r<br><\/li><li><strong>Semi-Random<\/strong> - Much of the map is randomized each game, including the location of ruins, creatures, weather, and certain quest branches.\r<br><\/li><li><strong>Sandbox or Story<\/strong> - Search for clues to your identity, what happened, and who's hunting you. Or simply test your mettle against man and nature alike. Play how you want!\r<br><\/li><li><strong>Abilities and Flaws<\/strong> - Choose abilities and flaws each time you play. Different combos unlock different abilities and quest branches.\r<br><\/li><li><strong>Crafting<\/strong> - Extensive crafting system which allows for substitutions of similar items. Make a rifle scope from half a pair of binoculars, or a noise trap from a pill bottle and pebbles.\r<br><\/li><li><strong>Desperate Combat<\/strong> - Detailed combat with moves like &quot;Tackle,&quot; &quot;Lure,&quot; &quot;Kick While Down,&quot; &quot;Demand Surrender,&quot; and &quot;Threaten.&quot;\r<br><\/li><li><strong>Realistic Wounds<\/strong> - Creatures have complex wound simulation, with multiple wound locations, infection, bleeding, and pain management.\r<br><\/li><li><strong>Realistic Metabolism<\/strong> - Hypothermia, fatigue, thirst, hunger, disease, intoxication, shelter...everything is tracked.\r<br><\/li><li><strong>Realistic Inventory<\/strong> - Complex inventory system with slots for holding, wearing, containers, and more. Fit items in grid spaces, and manage encumbrance.\r<br><\/li><li><strong>Hex-Based World Map<\/strong> - Navigate ruins, hills, forests, and plains in a hex-based map. Line-of-sight, elevation, and daylight matters.\r<br><\/li><li><strong>Tracking<\/strong> - Creatures leave their tracks and spoor on the map, which can be followed by others. Players can also hide their tracks.\r<br><\/li><li><strong>Hiding<\/strong> - Players can use hiding to avoid being seen while traveling the map, as well as during story encounters.\r<br><\/li><li><strong>Hunting<\/strong> - Trap small game for food and fur, or track and kill larger prey on the map for butchering.\r<br><\/li><li><strong>Hacking<\/strong> - Use hacking skills to unlock scavenged laptops, cellphones, smartphones, and tablets. Mine them for paydata, or snoop through personal files.\r<br><\/li><li><strong>Foraging<\/strong> - Search for edible plants and water, and use special skills to identify what's safe to eat.\r<br><\/li><li><strong>Haunting Soundtrack<\/strong> - Music composed by Josh Culler, specifically for NEO Scavenger, plays periodically, lending an atmosphere of loneliness and desperation. (Also accessible as mp3s outside game.)\r<br><\/li><li><strong>Creature AI<\/strong> - Wandering creatures go about their own business, hunting, scavenging, and hoarding. Morale affects their choices, and some will gang-up and cause trouble.\r<br><\/li><li><strong>Dynamic Weather<\/strong> - Temperature, rainfall, and night\/day are based on real-world data for autumn in the area. If you live long enough, you may see snow fall.\r<br><\/li><li><strong>Detroit<\/strong> - Take refuge from the wasteland in one of mankind's last bastions of safety. Buy supplies, get medical care, and seek clues in a cyberpunk-styled city.\r<br><\/li><li><strong>Trading Cards<\/strong> - Collect NEO Scavenger trading cards, badges, emoticons, and profile backgrounds!\r<\/li><\/ul>","about_the_game":"NEO Scavenger is a game where you must survive in the wasteland long enough to figure out who you are. Each turn, you must decide where to go, how to scavenge for supplies, and how to deal with anything and anyone you encounter. And with each passing minute, the pit in your stomach grows, your dehydration worsens, your muscles tire, and your body temperature drops in the cold autumn air. Choose your starting abilities carefully, because they and your wit are the only tools you have in the apocalypse!<h2 class=\"bb_tag\">Features<\/h2>\r<ul class=\"bb_ul\">\r<li><strong>Unique Setting<\/strong> - Near-future, post-apocalyptic Michigan with local cryptids and folklore. And something else beneath the surface...\r<br><\/li><li><strong>Turn-Based Play<\/strong> - Take your time with each turn, and play at your own pace. Save and quit when you want, and resume later.\r<br><\/li><li><strong>Permadeath<\/strong> - If you die, that's it. NEO Scavenger is balanced around a single difficulty level: permadeath. Your save will be deleted if you die. So choose every action carefully!\r<br><\/li><li><strong>No Grinding<\/strong> - There is no XP in NEO Scavenger. No levelling-up. Instead, progress comes from learning how to play the game better, and using your strengths to your advantage.\r<br><\/li><li><strong>Semi-Random<\/strong> - Much of the map is randomized each game, including the location of ruins, creatures, weather, and certain quest branches.\r<br><\/li><li><strong>Sandbox or Story<\/strong> - Search for clues to your identity, what happened, and who's hunting you. Or simply test your mettle against man and nature alike. Play how you want!\r<br><\/li><li><strong>Abilities and Flaws<\/strong> - Choose abilities and flaws each time you play. Different combos unlock different abilities and quest branches.\r<br><\/li><li><strong>Crafting<\/strong> - Extensive crafting system which allows for substitutions of similar items. Make a rifle scope from half a pair of binoculars, or a noise trap from a pill bottle and pebbles.\r<br><\/li><li><strong>Desperate Combat<\/strong> - Detailed combat with moves like &quot;Tackle,&quot; &quot;Lure,&quot; &quot;Kick While Down,&quot; &quot;Demand Surrender,&quot; and &quot;Threaten.&quot;\r<br><\/li><li><strong>Realistic Wounds<\/strong> - Creatures have complex wound simulation, with multiple wound locations, infection, bleeding, and pain management.\r<br><\/li><li><strong>Realistic Metabolism<\/strong> - Hypothermia, fatigue, thirst, hunger, disease, intoxication, shelter...everything is tracked.\r<br><\/li><li><strong>Realistic Inventory<\/strong> - Complex inventory system with slots for holding, wearing, containers, and more. Fit items in grid spaces, and manage encumbrance.\r<br><\/li><li><strong>Hex-Based World Map<\/strong> - Navigate ruins, hills, forests, and plains in a hex-based map. Line-of-sight, elevation, and daylight matters.\r<br><\/li><li><strong>Tracking<\/strong> - Creatures leave their tracks and spoor on the map, which can be followed by others. Players can also hide their tracks.\r<br><\/li><li><strong>Hiding<\/strong> - Players can use hiding to avoid being seen while traveling the map, as well as during story encounters.\r<br><\/li><li><strong>Hunting<\/strong> - Trap small game for food and fur, or track and kill larger prey on the map for butchering.\r<br><\/li><li><strong>Hacking<\/strong> - Use hacking skills to unlock scavenged laptops, cellphones, smartphones, and tablets. Mine them for paydata, or snoop through personal files.\r<br><\/li><li><strong>Foraging<\/strong> - Search for edible plants and water, and use special skills to identify what's safe to eat.\r<br><\/li><li><strong>Haunting Soundtrack<\/strong> - Music composed by Josh Culler, specifically for NEO Scavenger, plays periodically, lending an atmosphere of loneliness and desperation. (Also accessible as mp3s outside game.)\r<br><\/li><li><strong>Creature AI<\/strong> - Wandering creatures go about their own business, hunting, scavenging, and hoarding. Morale affects their choices, and some will gang-up and cause trouble.\r<br><\/li><li><strong>Dynamic Weather<\/strong> - Temperature, rainfall, and night\/day are based on real-world data for autumn in the area. If you live long enough, you may see snow fall.\r<br><\/li><li><strong>Detroit<\/strong> - Take refuge from the wasteland in one of mankind's last bastions of safety. Buy supplies, get medical care, and seek clues in a cyberpunk-styled city.\r<br><\/li><li><strong>Trading Cards<\/strong> - Collect NEO Scavenger trading cards, badges, emoticons, and profile backgrounds!\r<\/li><\/ul>","supported_languages":"English","reviews":"\u201cone of the best single player turn-based RPGs I\u2019ve played for a long time.\u201d\r<br><a target=\"_blank\" href=\"http:\/\/www.rockpapershotgun.com\/2014\/01\/17\/impressions-neo-scavenger\/\"  >Rock Paper Shotgun<\/a>\r<br>\r<br>\u201cIn short, this game is terrible...Buy it.\u201d\r<br><a target=\"_blank\" href=\"https:\/\/steamcommunity.com\/linkfilter\/?url=http:\/\/www.themittani.com\/features\/neo-scavenger-terrible-good-game\"  >TheMittani<\/a>\r<br>\r<br>\u201cIt may be a little hard to get into for some, but it's absolutely hard to put down.\u201d\r<br><a target=\"_blank\" href=\"https:\/\/steamcommunity.com\/linkfilter\/?url=http:\/\/jayisgames.com\/archives\/2015\/01\/neo_scavenger.php\"  >JayIsGames<\/a>\r<br>","header_image":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/header.jpg?t=1447358462","website":"http:\/\/bluebottlegames.com\/main\/node\/2","pc_requirements":{"minimum":"<strong>Minimum:<\/strong>\r<br><ul class=\"bb_ul\"><li><strong>OS:<\/strong> Microsoft\u00ae Windows\u00ae XP (32 bit), Windows Server 2008 (32 bit), Windows Vista\u00ae (32 bit), Windows 7 (32 bit and 64 bit), Windows 8 (32 bit and 64 bit), or Windows Server 2012 (64 bit)\r<br><\/li><li><strong>Processor:<\/strong> 2.33GHz or faster x86-compatible processor, or Intel Atom 1.6GHz or faster processor for netbooks\r<br><\/li><li><strong>Memory:<\/strong> 1 GB RAM\r<br><\/li><li><strong>Graphics:<\/strong> 128MB of graphics memory\r<br><\/li><li><strong>Storage:<\/strong> 75 MB available space\r<br><\/li><li><strong>Sound Card:<\/strong> Any\r<br><\/li><li><strong>Additional Notes:<\/strong> Please try the free demo to verify that it works for you!\r<\/li><\/ul>"},"mac_requirements":{"minimum":"<strong>Minimum:<\/strong>\r<br><ul class=\"bb_ul\"><li><strong>OS:<\/strong> Mac OS X v10.6, v10.7, v10.8, or v10.9\r<br><\/li><li><strong>Processor:<\/strong> Intel Core\u2122 Duo 1.83GHz or faster processor\r<br><\/li><li><strong>Memory:<\/strong> 1 GB RAM\r<br><\/li><li><strong>Graphics:<\/strong> 128MB of graphics memory\r<br><\/li><li><strong>Storage:<\/strong> 75 MB available space\r<br><\/li><li><strong>Sound Card:<\/strong> Any\r<br><\/li><li><strong>Additional Notes:<\/strong> Please try the free demo to verify that it works for you!\r<\/li><\/ul>"},"linux_requirements":{"minimum":"<strong>Minimum:<\/strong>\r<br><ul class=\"bb_ul\"><li><strong>OS:<\/strong> Red Hat\u00ae Enterprise Linux\u00ae (RHEL) 5.6 or later (32 bit and 64 bit), openSUSE\u00ae 11.3 or later (32 bit and 64 bit), or Ubuntu 10.04 or later (32 bit and 64 bit)\r<br><\/li><li><strong>Processor:<\/strong> 2.33GHz or faster x86-compatible processor, or Intel Atom 1.6GHz or faster processor for netbooks\r<br><\/li><li><strong>Memory:<\/strong> 1 GB RAM\r<br><\/li><li><strong>Graphics:<\/strong> 128MB of graphics memory\r<br><\/li><li><strong>Storage:<\/strong> 75 MB available space\r<br><\/li><li><strong>Sound Card:<\/strong> Any\r<br><\/li><li><strong>Additional Notes:<\/strong> Please try the free demo to verify that it works for you!\r<\/li><\/ul>"},"developers":["Blue Bottle Games"],"publishers":["Blue Bottle Games"],"demos":[{"appid":270680,"description":""}],"price_overview":{"currency":"THB","initial":31500,"final":31500,"discount_percent":0},"packages":[30010],"package_groups":[{"name":"default","title":"Buy NEO Scavenger","description":"","selection_text":"Select a purchase option","save_text":"","display_type":0,"is_recurring_subscription":"false","subs":[{"packageid":30010,"percent_savings_text":"","percent_savings":0,"option_text":"NEO Scavenger - \u0e3f315.00","option_description":"","can_get_free_license":"0","is_free_license":false,"price_in_cents_with_discount":31500}]}],"platforms":{"windows":true,"mac":true,"linux":true},"metacritic":{"score":77,"url":"http:\/\/www.metacritic.com\/game\/pc\/neo-scavenger"},"categories":[{"id":2,"description":"Single-player"},{"id":29,"description":"Steam Trading Cards"}],"genres":[{"id":"23","description":"Indie"},{"id":"3","description":"RPG"},{"id":"2","description":"Strategy"}],"screenshots":[{"id":0,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_0206930559928876bc32c4fa9928b5454efb302b.600x338.jpg?t=1447358462","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_0206930559928876bc32c4fa9928b5454efb302b.1920x1080.jpg?t=1447358462"},{"id":1,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_92b26368f8fa5e6a7ceaf8fb037c6db8cd23bc30.600x338.jpg?t=1447358462","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_92b26368f8fa5e6a7ceaf8fb037c6db8cd23bc30.1920x1080.jpg?t=1447358462"},{"id":2,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_f72c7858ecc10a74598c6fa198203e75dd65db05.600x338.jpg?t=1447358462","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_f72c7858ecc10a74598c6fa198203e75dd65db05.1920x1080.jpg?t=1447358462"},{"id":3,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_dadcda4155cca8ce30c002b514fd394dce0e1dcc.600x338.jpg?t=1447358462","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_dadcda4155cca8ce30c002b514fd394dce0e1dcc.1920x1080.jpg?t=1447358462"},{"id":4,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_2083362cff7b5bfb364ecb2fbefbd547d4ec5b31.600x338.jpg?t=1447358462","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_2083362cff7b5bfb364ecb2fbefbd547d4ec5b31.1920x1080.jpg?t=1447358462"},{"id":5,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_da543bef653ad123bc1becea767f021cb01017fd.600x338.jpg?t=1447358462","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_da543bef653ad123bc1becea767f021cb01017fd.1920x1080.jpg?t=1447358462"},{"id":6,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_1355c46324cb4f9463feb75e330fa9a2dd2c6a45.600x338.jpg?t=1447358462","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_1355c46324cb4f9463feb75e330fa9a2dd2c6a45.1920x1080.jpg?t=1447358462"},{"id":7,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_6f9eeeb78aebcc359468f02a5f23b2f234ca5d19.600x338.jpg?t=1447358462","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_6f9eeeb78aebcc359468f02a5f23b2f234ca5d19.1920x1080.jpg?t=1447358462"},{"id":8,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_31c1dee9d01cc9483f191381ae50120db85aa74b.600x338.jpg?t=1447358462","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_31c1dee9d01cc9483f191381ae50120db85aa74b.1920x1080.jpg?t=1447358462"},{"id":9,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_325acf9783dfa05c7e4479080da05e076ba82470.600x338.jpg?t=1447358462","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_325acf9783dfa05c7e4479080da05e076ba82470.1920x1080.jpg?t=1447358462"},{"id":10,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_053c8fef9dfc9550d642c1ab9cedb5e0592dca66.600x338.jpg?t=1447358462","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_053c8fef9dfc9550d642c1ab9cedb5e0592dca66.1920x1080.jpg?t=1447358462"},{"id":11,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_42cd7dc6f3ff5e9fbe3b5542752e6a050aad32f4.600x338.jpg?t=1447358462","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_42cd7dc6f3ff5e9fbe3b5542752e6a050aad32f4.1920x1080.jpg?t=1447358462"},{"id":12,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_09926eb3771a55c952dfe9d55e3bd8a1f0e0879a.600x338.jpg?t=1447358462","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_09926eb3771a55c952dfe9d55e3bd8a1f0e0879a.1920x1080.jpg?t=1447358462"},{"id":13,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_700aa36ac9264b4d02294a837062971318f834af.600x338.jpg?t=1447358462","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/ss_700aa36ac9264b4d02294a837062971318f834af.1920x1080.jpg?t=1447358462"}],"movies":[{"id":2030147,"name":"NEO Scavenger Gameplay Trailer - Aug 2012","thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/2030147\/movie.293x165.jpg?t=1447359532","webm":{"480":"http:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/2030147\/movie480.webm?t=1447359532","max":"http:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/2030147\/movie_max.webm?t=1447359532"},"highlight":true}],"recommendations":{"total":2146},"release_date":{"coming_soon":false,"date":"16 Dec, 2014"},"support_info":{"url":"","email":"dcfedor@bluebottlegames.com"},"background":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/248860\/page_bg_generated_v6b.jpg?t=1447358462"}}}

To make JSON easier to read and make sense of, you can use a tool like JSON Editor Online which gives you a nicely readable overview

So what we’re looking for there is the following piece

"price_overview": {
    "currency": "THB",
    "initial": 31500,
    "final": 31500,
    "discount_percent": 0
}

So we parse that data out, and the same from our stored data

name = j[appid]['data']['name'].encode('utf-8', 'ignore')

discount = j[appid]['data']['price_overview']['discount_percent']
old_discount = old[appid]['data']['price_overview']['discount_percent']

price = j[appid]['data']['price_overview']['final']
old_price = old[appid]['data']['price_overview']['final']

price_fmt = config['currency'] + str(float(price) / 100)
old_price_fmt = config['currency'] + str(float(old_price) / 100)

Now simply check if price has changed

if discount > old_discount or price < old_price:

and do what you want from there on.

Full source code is available in a GitHub repo

Incoming search terms:

  • store php5?appids=

Asbra

Posts Facebook

Blogging out of many years of experience with gamehacking, programming, reverse-engineering and general tomfoolery.

No Comments

Be the first to start the conversation.

Leave a Reply