UPDATE: If you want to see an actual documentation on this API, check out RJackson's documentation here.
Some people were asking us how we are getting all these prices in such a neat way, including different countries. So, here's a blog post explaining that!
All began when I saw SteamCalculator's getGames script, which is used to get prices for all games currently on Steam.
I quickly modified the script to get prices for different countries, and got it working with our database. And then the problems began. The first one, is that Steam would sometimes just put "Uninitialized" instead of actual game's name, and prices were wrong.
I started looking at why it was happening, and couldn't find any bug in the code, but rather it is a bug in Steam's store front (it even happens sometimes when you just visit the store). This script uses store search, which returns HTML. It's not ideal, but it works.
Big Picture HTTP API
I was messing around in Big Picture, and then was curious about how the whole thing worked. I logged some requests it made, and quickly realized that it was over HTTP.
I pointed store.steampowered.com to 127.0.0.1, and started logging requests, it was easier for me to do it this way, because I could clearly see what requests the client makes to web services. And here's what I got:
"GET /api/featured/?cc=EE&l=english&v=1 HTTP/1.1" "-" "Valve/Steam HTTP Client 1.0 (tenfoot)"
"GET /api/featuredcategories/?cc=EE&l=english&v=1&trailer=1 HTTP/1.1" "-" "Valve/Steam HTTP Client 1.0 (tenfoot)"
"GET /api/appdetails/?appids=730&cc=EE&l=english&v=1 HTTP/1.1" "-" "Valve/Steam HTTP Client 1.0 (tenfoot)"
"GET /api/appuserdetails/?appids=730&cc=EE&l=english&v=1 HTTP/1.1" "-" "Valve/Steam HTTP Client 1.0 (tenfoot)"
Jackpot! /api/appdetails/?appids= is used to get all store information about the game in a neat JSON output, including: prices, genres, categories, packages, screenshots, movies, and lots of different stuff.
I was only interested in prices, so I only used price_overview section. It includes raw price information:
- currency: EUR, GPB, USD, RUB, BRL
- initial: Initial game price in cents
- final: Price in cents after applying discount percentage
- discount_percent: Discount percent, simply "75" or any other value
Looking at the GET parameter ?appids, it implies usage of multiple appids at same time. I tried putting couple of appids separated by commas, and it worked. It returned all the information for requested appids. Amazing!
I wrote some code to get all appids from our database, and separate it into chunks of ~250 appids, and request information via API. It worked flawlessly. I made it actually parse the response, and put information to the database, and then prices viewing went live on the website.
Couple of weeks later, I started noticing weird stuff going on in the database, like each update random games would get price of zero, or incredibly high price. Nothing seemed wrong in the code, and I tried logging each request to a file. The problem is that requesting a lot of apps at same time, seems to "break" Steam, and it starts not putting prices in the response. As for high prices, it randomly decides to return price of full game package, or developer package, instead of actual requested app.
But that's not all the problems. There are some games in the store that if you visit directly (by using appid) it will redirect you to another game (like full package). It does NOT do that in the API, and this makes it very weird to sort through prices.
I hope that Valve will continue making improvements to their API, and sometime publish it for public use.
P.S. To get prices for packages, you would use /api/packagedetails/?packageids= instead. And "price" instead of "price_overview".