Steam-Powered DOTA on Rails

Originally published at:

After writing a couple of “serious” articles on building authentication systems with Rails, I decided to have a break and play some games. I just Googled for online games and stumbled upon Dota 2. Dota 2 is an immensely popular (more than 10,000,000 unique players last month) battle arena game developed by Valve.

The game is quite complex and some web services like DotaBuff were created to help players track their progress. After visiting DotaBuff and seeing all of its beautiful tables and graphs, I just couldn’t stop myself from searching for information about the Dota 2 API. The Ruby thing to do is to share my research with you!

In this article, we are going to work with Dota 2 API. We’ll create an app that borrows basic functionality from DotaBuff: a user logs in via Steam and sees a list of his recent matches and statistics. I’ll pinpoint all the gotchas I faced during development of this app and give some advice on how this can be implemented in production.

Source code is available on GitHub.

Working demo can be found at

What is Dota?

According to Wikipedia, Dota 2 is a free-to-play multiplayer online battle arena video game. It is the stand-alone sequel to the Defense of the Ancients modification for Warcraft III: The Frozen Throne. Its mechanics are quite complex, so I will just give you a quick overview.

Originally, DotA (Defense of the Ancients) was a custom map for Warcraft III developed by a person called IceFrog. After a couple of years, it became so popular that Valve decided to hire IceFrog and create a standalone version of the game, which they called it Dota 2. It was released in 2013 and now is considered one of the most popular online games in the world. Many professional competitions with money prizes are being held and streams by experienced players are being watched by hundreds of people.

Talking about gameplay, there are two teams (Radiant, good, and Dire, evil) with (typically) 5 players each. At the start of the game, each player picks one hero from a pool containing more than 100 heroes and enters the game. Each team has their base and the ultimate goal is to destroy the main building on the enemy’s base while protecting your own. Players can buy various artifacts (each hero may take up to 6 items at once), kill creeps (creatures, controlled by AI) or enemy heroes to earn gold and experience. Each hero has unique set of abilities that players use to help their teammates or wreck havoc upon enemies. That’s Dota in a nutshell.

Let’s proceed and see what goodies the Dota 2 API present.

Continue reading this article on SitePoint

Another awesome article. Great piece of writing :thumbsup:.

Thank you!

Hi. You get it when loggin in I suppose?

Hi. Right

Well, I’ve browsed logs and seems that the problem is here: Looks like you have no matches therefore matches returns nil. Could you try logging in once again? If this does help, I’ll update the article accordingly.
Ok, login works. But it doesn’t show any matches. Maybe because my profile in dota closed :smile:

Ah, of course that’s the reason. To see some info you have to make it public and allow 3rd party services to access it (it should be somewhere in Dota settings). The code is updated however I’ve opened this issue to discuss if it is okay for matches to return nil in some scenarios.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.