Dota 2 api heroes and icons
Dota 2 API: Hero Details
116 heroes and counting
Getting Hero Details with GetHeroes
This section will have us start making calls to the Dota 2 API provided by Steam. We’ll begin with a fairly straightforward call to GetHeroes , which will return a list of all available heroes in Dota at the moment. Then, we can use the data that we get in response and a URL for images to display hero portraits. Let’s start with a simple GET request to the following URL:
As noted previously, replace APIKEY with your own API key or the variable storing it. We can use it in our server-side code, as detailed below. This request also takes the common options listed in the Getting Started section.
Sample Server-Side Code
An example follows of how the JavaScript might look if using Node. js, Express, and Express Handlebars. You can use this as a template for your GET requests. This example will simply put a huge wall of text (the JSON object as plaintext) on a page named test and prints the JSON response to the console, which isn’t of much use to us right now, but we can tweak it down the line for our purposes, which we will see at the end of this section. For this sample code, your test. handlebars should have <> in it. You can store your API key outside of the function as a string global variable.
The result is a list of all 116 current heroes. For those that have played the game for a while, that Skeleton King is still Skeleton King (THE ONE TRUE KING), despite Valve changing his in-game name to Wraith King (for pressing ceremonial reasons).
For fun, let’s try using the language option (one of the common options outlined above) to get the heroes in Simplified Chinese (using zh_cn for the language).
The result now includes a localized name (in Simplified Chinese) for each hero! Tiny is literally “little little”.
Breaking Down the GetHeroes Response
The response is fairly straightforward, and there aren’t a lot of different keys to deal with in the response object. Here’s a breakdown of the response that we get:
- result
- heroes
- name : The hero’s in-game tokenized string name
- id : The hero’s ID
- localized_name : The language-specific name of the hero for displaying the name; this field is not included if a language is not specified in the API call
- status : Status of the API call
- count : The total number of heroes in the list
- heroes
Hero Images
Using the information from our response from GetHeroes , we can get hero portraits from Valve’s servers. The URL for the images follows the following format:
Replace HERONAME with the name of the hero obtained from the response to the GetHeroes call, but with the prefix npc_dota_hero_ removed. For example, use witch_doctor instead of npc_dota_hero_witch_doctor .
Replace SUFFIX with one of the four following options:

