dota is a Ruby client for the Dota 2 WebAPI. It provides an easy way to access matches, players, heroes, items, and other public Dota 2 objects in an opinionated manner.
Currently supported endpoints:
This gem is in alpha, keep that in mind when upgrading.
- Support for more endpoints
- Validations and error classes
- More configuration options
- Move API documentation to readthedocs.org or somewhere else
- Better search filters
- Computed attributes such as win rates, hero usage, etc.
Add this line to your application's Gemfile:
gem 'dota'And then execute:
$ bundle
Or install it yourself as:
$ gem install dota
Dota.configure do |config|
config.api_key = "YOUR_STEAM_API_KEY"
endGet your Steam API key here.
api = Dota.api
api.heroes(43) # (Cached) A single hero - Death Prophet
api.heroes # (Cached) All heroes
api.items(114) # (Cached) A single item - Heart of Tarrasque
api.items # (Cached) All items
api.cosmetic_rarities # All cosmetic rarities
api.leagues # All leagues
api.matches(789645621) # A single match - Newbee vs Vici Gaming
api.matches # A list of matches
api.matches(hero_id: 43) # Allowed options:
#
# :hero_id - Integer, With this hero. See Dota::API::Hero::MAPPING
# :after - Integer, With match ids equal to greater than this
# :player_id - Integer, With this player (Steam ID)
# :league_id - Integer, In this league. Use Dota.leagues to get a list of leagues
# :mode_id - Integer, In this game mode. See Dota::API::Match::MODES
# :skill_level - Integer, In this skill level (ignored if :player_id is provided). See Dota::API::Match::SKILL_LEVELS
# :from - Integer, Minimum timestamp
# :to - Integer, Maximum timestamp
# :min_players - Integer, With at least this number of players
# :league_only - Boolean, Only league matches
# :limit - Integer, Amount of matches to return (default is 100)
api.friends(76561198052976237) # All friends of userFor the unsupported endpoints, you can use api.get. The following code is similar to api.matches(789645621) except that it only returns the response body.
api.get("IDOTA2Match_570", "GetMatchDetails", match_id: 789645621)hero.id # Integer, ID of the hero
hero.name # String, Name of the hero
hero.image_url # String, URL of the hero portraititem.id # Integer, ID of the item
item.name # String, Name of the item
item.image_url # String, URL of the item imageleague.id # Integer, ID of the league
league.name # String, Name of the league
league.description # String, A description of the league
league.url # String, URL of the league's websiteCaveat: Getting a list of matches via api.matches will call GetMatchHistory which has very few attributes for the matches returned (obviously for performance reasons), as opposed to getting info about a particular match via api.matches(id) which will instead call GetMatchDetails. In both cases, the matches returned will be instances of Dota::API::Match. In the future, there will be subclasses to distinguish the two.
When an instance method in a Dota::API::Match class returns nil, it most likely means the endpoint called doesn't provide it yet.
match.id # => 789645621
match.league_id # => 600
match.type # => "Tournament"
match.type_id # => 2
match.mode # => "Captain's Mode"
match.mode_id # => 2
match.drafts # => [Dota::API::Match::Draft, ...]
match.players # => [Dota::API::Match::Player, ...]
match.sequence # => 709365483
match.starts_at # => 2014-07-21 20:12:50 UTC
match.duration # => 908
match.winner # => :radiant
match.first_blood # => 33
match.positive_votes # => 34701
match.negative_votes # => 13291
match.season # => nil
match.players_count # => 10
match.cluster # => 111
match.radiant_tower_status # => 2039
match.dire_tower_status # => 1974
match.radiant_barracks_status # => 63
match.dire_barracks_status # => 63player.id # => 98887913
player.hero # => Dota::API::Hero
player.items # => [Dota::API::Item, ...]
player.slot # => 0
player.status # => :played
player.level # => 11
player.kills # => 2
player.deaths # => 1
player.assists # => 13
player.last_hits # => 45
player.denies # => 0
player.gold # => 649
player.gold_spent # => 6670
player.gpm # => 437
player.xpm # => 460
player.hero_damage # => 3577
player.tower_damage # => 153
player.hero_healing # => 526draft.order # Integer, 1-20
draft.pick? # Boolean, true if the draft is a pick, and not a ban
draft.team # Symbol, :radiant or :dire
draft.hero # Dota::API::Herorarity.id # Integer, ID of rarity, used for indexing
rarity.order # Integer, Sorting and logical order, from most distributed to least
rarity.name # String, Localized display name
rarity.color # String, The hexadecimal RGB tuplefriend.id # String, 64-bit Steam ID
friend.relationship # String, Relation to the user
friend.made_at # Time, When the friend was added to the list- Fork it!
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request