Parsing item prices from Steam Community Market

At one point I was contracted to make a WordPress plugin that displays some basic Steam Market information on an item, like its name, image, price, volume, etc. It actually turned out less trivial than it seems, because the Steam public API doesn’t expose any functionality related the Steam Market, probably to make developing market bots slightly harder.

After about an hour of inspecting HTTP requests in Fiddler and then some more StackOverflow researching, I managed to find something to work with. The actual Steam Market listings use an internal API endpoint to populate the page via AJAX, which returns some of the information I needed – lowest price, median price and volume.


To access this internal API endpoint, you'll have to write a request similar to this:

Which returns the following type of JSON response:

The median_price and volume properties may not be present sometimes – I’m not really sure why.

The request itself takes a total of 3 parameters: appid (which is the game ID), currency (which is the currency ID), market_hash_name (which is the item’s url-encoded name). You can find the game ID and item name by inspecting the address string of a market listing in your browser:

In this screenshot 730 is the game ID for CS:GO and the selected url-encoded string is the item’s name. The name should be an exact match of what you see there - if you forget to include any characters, the API will not return anything.

As for the currency, I’m not sure what’s the exact list of IDs and where you can find them, but currency=1 corresponds to USD.

Getting the item image proved a bit more difficult – there doesn’t seem to be any obvious pattern to determine the image url from the item’s name or anything like that. However, there is another internal API endpoint that Steam uses to render the item information.

This will return the HTML code, used to display the listings for the specified stock, along with extended listing information. You'd want to set count=1 to only return results for one item, reducing the size of the incoming JSON.

The HTML element you’re looking for is hidden in the results_html property: //img[@class="market_listing_item_img"]

And a typical image src looks like this:
http://steamcommunity-a.akamaihd.net/economy/image/fWFc82js0fmoRAP-qOIPu5THSWqfSmTELLqcUywGkijVjZULUrsm1j-9xgEAaR4uURrwvz0N3Jy1CKDZXOIGn402s5YAjTJuwVkvZuLkZDNhIQeQAKEJDvBi9l7qWWki5sAy6hNzgg/240fx240f

In the very end of that url you can see it also sets the dimensions for the image - 240fx240f. Changing these values will make the server return images of the given size, but it will always remain proportional and will not scale above its maximum size – the empty space will be transparent instead and the actual image will be centered.


I implemented the plugin using the shortcode pattern. It can take multiple different parameters to utilize these API endpoints to their fullest potential. Here’s an example:

In case someone is interested in making something similar, you can check out the source code on github.

Comments