Dota 2 API: Getting Started

Getting a Steam account and an API key

Getting an API Key (and Steam Account)

This section will be a brief walkthrough of how to get an API key for use with Steam's web APIs and some considerations to be aware of when using API keys in general and with Steam's web APIs.

To start, we must get an API key from Steam. This is necessary for making the API calls to the Dota 2 web API. We go to the Steam Community API key registration page. You may be greeted with a login/registration page for Steam, if you are not already logged in:

Logging in or registering for a Steam account

Log in or register for an account, and you will see the following page:

Registering for an API key on the Steam Community

You should receive a unique API key, which you should not share with others. The API key is used to identify who is making requests to the web API, and should be kept secure to prevent abuse by others. The API key is used to identify who is making requests to Steam's web APIs, and they can restrict or revoke access for keys that appear to be abusing the system (such as making extremely frequent API calls, etc.). To prevent this from happening to your key, remember to remove it when posting code online!

You can use server-side requests to help keep your API key safe. In subsequent sections of this how-to, the variable APIKEY should store your API key in your code; if you see APIKEY, then replace that with your own API key or a variable storing your API key.

Cross-Origin Policy

An important thing to note is that calls to Steam's APIs will not allow cross-origin requests. Issues arising from the same-origin policy may be encountered. You will have to fetch the data through your server, not the browser (which also helps with keeping your API key safe). I recommend using Node.js with Express for your server-side needs; we will assume that you know how to set this up and go forward from here, so we won't cover this in our how-to. However, many of the subsequent code samples will be using server-side code in Node.js and Express with Handlebars.

Now that we have an API key, we can start making requests for Dota-related data. We'll start simple with getting heroes.

Common Options

For all the subsequent API calls in this how-to, there are a few common options that are available:

The language and format parameters can be left blank, and it is assumed that they are the default values.