vinnicc / dota Goto Github PK
View Code? Open in Web Editor NEWRuby client for the Dota 2 WebAPI
License: MIT License
Ruby client for the Dota 2 WebAPI
License: MIT License
If you try to get a team that has been disbanded. For example: 2243650
:
Dota.api.teams(2243650).id
You'll get 2243651
, not 2243650
.
But you can get the right data with below api:
Dota.api.get("IDOTA2Teams_570", "GetTeamInfo", team_id: 2243650)
And you'll see "disbanded"=>true
.
Error appeared again.
But this time it's only gives on radiant side. Dire is ok. Here's raw data.
Hope it'd help to solve problem.
{
"players": [
{
"account_id": 115887413,
"name": "Pakoo",
"hero_id": 0,
"team": 2
},
{
"account_id": 180247844,
"name": "Meow >:3",
"hero_id": 76,
"team": 0
},
{
"account_id": 201217135,
"name": "foRa",
"hero_id": 110,
"team": 1
},
{
"account_id": 258607868,
"name": "matvievskiy1993",
"hero_id": 7,
"team": 1
},
{
"account_id": 99972268,
"name": "2ez",
"hero_id": 26,
"team": 0
},
{
"account_id": 66094251,
"name": "Братишка",
"hero_id": 72,
"team": 1
},
{
"account_id": 106519437,
"name": "Lipa",
"hero_id": 52,
"team": 1
},
{
"account_id": 80316220,
"name": "Crash.295",
"hero_id": 112,
"team": 1
},
{
"account_id": 143344731,
"name": "MafionSО_о",
"hero_id": 12,
"team": 0
},
{
"account_id": 87191277,
"name": "eLGam1ngTob",
"hero_id": 96,
"team": 0
},
{
"account_id": 172888585,
"name": "Love_<3Sinon",
"hero_id": 87,
"team": 0
},
{
"account_id": 140584095,
"name": "-G1n.",
"hero_id": 0,
"team": 4
}
]
,
"dire_team": {
"team_name": "-The Rejects-",
"team_id": 1186217,
"team_logo": 529515190482385565,
"complete": false
},
"lobby_id": 24091671383438427,
"match_id": 1611055562,
"spectators": 35,
"league_id": 3333,
"stream_delay_s": 10,
"radiant_series_wins": 0,
"dire_series_wins": 0,
"series_type": 0,
"league_tier": 1,
"scoreboard": {
"duration": 1627.4290771484375,
"roshan_respawn_timer": 413,
"radiant": {
"score": 12,
"tower_state": 1824,
"barracks_state": 60,
"picks": [
{
"hero_id": 26
},
{
"hero_id": 87
},
{
"hero_id": 12
},
{
"hero_id": 96
},
{
"hero_id": 76
}
]
,
"bans": [
{
"hero_id": 4
},
{
"hero_id": 75
},
{
"hero_id": 97
},
{
"hero_id": 70
},
{
"hero_id": 88
}
]
,
"players": [
{
"player_slot": 1,
"account_id": 180247844,
"hero_id": 76,
"kills": 3,
"death": 8,
"assists": 0,
"last_hits": 26,
"denies": 11,
"gold": 741,
"level": 11,
"gold_per_min": 224,
"xp_per_min": 291,
"ultimate_state": 1,
"ultimate_cooldown": 105,
"item0": 41,
"item1": 63,
"item2": 77,
"item3": 0,
"item4": 27,
"item5": 0,
"respawn_timer": 36,
"position_x": -6427.39111328125,
"position_y": -5322.5830078125,
"net_worth": 3661
},
{
"player_slot": 2,
"account_id": 143344731,
"hero_id": 12,
"kills": 0,
"death": 4,
"assists": 1,
"last_hits": 132,
"denies": 18,
"gold": 894,
"level": 12,
"gold_per_min": 311,
"xp_per_min": 304,
"ultimate_state": 3,
"ultimate_cooldown": 0,
"item0": 11,
"item1": 63,
"item2": 137,
"item3": 0,
"item4": 0,
"item5": 0,
"respawn_timer": 33,
"position_x": -6583.7529296875,
"position_y": -5923.0869140625,
"net_worth": 7744
},
{
"player_slot": 3,
"account_id": 87191277,
"hero_id": 96,
"kills": 4,
"death": 11,
"assists": 3,
"last_hits": 78,
"denies": 6,
"gold": 54,
"level": 12,
"gold_per_min": 299,
"xp_per_min": 330,
"ultimate_state": 3,
"ultimate_cooldown": 0,
"item0": 1,
"item1": 40,
"item2": 34,
"item3": 42,
"item4": 182,
"item5": 214,
"respawn_timer": 0,
"position_x": -6689.9736328125,
"position_y": -5459.34130859375,
"net_worth": 3959
},
{
"player_slot": 4,
"account_id": 99972268,
"hero_id": 26,
"kills": 1,
"death": 8,
"assists": 4,
"last_hits": 13,
"denies": 6,
"gold": 885,
"level": 11,
"gold_per_min": 210,
"xp_per_min": 235,
"ultimate_state": 1,
"ultimate_cooldown": 30,
"item0": 16,
"item1": 0,
"item2": 60,
"item3": 214,
"item4": 42,
"item5": 0,
"respawn_timer": 33,
"position_x": -6707.912109375,
"position_y": -5930.52783203125,
"net_worth": 3210
},
{
"player_slot": 5,
"account_id": 172888585,
"hero_id": 87,
"kills": 2,
"death": 7,
"assists": 2,
"last_hits": 12,
"denies": 1,
"gold": 274,
"level": 9,
"gold_per_min": 171,
"xp_per_min": 173,
"ultimate_state": 1,
"ultimate_cooldown": 74,
"item0": 43,
"item1": 180,
"item2": 36,
"item3": 46,
"item4": 0,
"item5": 0,
"respawn_timer": 41,
"position_x": -6634.20458984375,
"position_y": -5573.8994140625,
"net_worth": 2389
}
]
,
"abilities": [
{
"ability_id": 5391,
"ability_level": 1
},
{
"ability_id": 5392,
"ability_level": 4
},
{
"ability_id": 5393,
"ability_level": 4
},
{
"ability_id": 5394,
"ability_level": 2
}
]
,
"abilities": [
{
"ability_id": 5065,
"ability_level": 4
},
{
"ability_id": 5066,
"ability_level": 4
},
{
"ability_id": 5068,
"ability_level": 2
},
{
"ability_id": 5067,
"ability_level": 2
}
]
,
"abilities": [
{
"ability_id": 5514,
"ability_level": 3
},
{
"ability_id": 5515,
"ability_level": 4
},
{
"ability_id": 5516,
"ability_level": 3
},
{
"ability_id": 5517,
"ability_level": 2
}
]
,
"abilities": [
{
"ability_id": 5044,
"ability_level": 4
},
{
"ability_id": 5045,
"ability_level": 4
},
{
"ability_id": 5046,
"ability_level": 1
},
{
"ability_id": 5047,
"ability_level": 2
}
]
,
"abilities": [
{
"ability_id": 5458,
"ability_level": 3
},
{
"ability_id": 5459,
"ability_level": 4
},
{
"ability_id": 5460,
"ability_level": 1
},
{
"ability_id": 5461,
"ability_level": 1
}
]
},
"dire": {
"score": 38,
"tower_state": 2047,
"barracks_state": 63,
"picks": [
{
"hero_id": 52
},
{
"hero_id": 112
},
{
"hero_id": 72
},
{
"hero_id": 7
},
{
"hero_id": 110
}
]
,
"bans": [
{
"hero_id": 39
},
{
"hero_id": 85
},
{
"hero_id": 54
},
{
"hero_id": 93
},
{
"hero_id": 21
}
]
,
"players": [
{
"player_slot": 1,
"account_id": 258607868,
"hero_id": 7,
"kills": 2,
"death": 2,
"assists": 9,
"last_hits": 23,
"denies": 0,
"gold": 537,
"level": 11,
"gold_per_min": 276,
"xp_per_min": 294,
"ultimate_state": 1,
"ultimate_cooldown": 14,
"item0": 180,
"item1": 36,
"item2": 1,
"item3": 0,
"item4": 0,
"item5": 0,
"respawn_timer": 0,
"position_x": 5986.4365234375,
"position_y": -4551.9921875,
"net_worth": 5802
},
{
"player_slot": 2,
"account_id": 66094251,
"hero_id": 72,
"kills": 7,
"death": 6,
"assists": 6,
"last_hits": 25,
"denies": 2,
"gold": 1380,
"level": 11,
"gold_per_min": 338,
"xp_per_min": 281,
"ultimate_state": 3,
"ultimate_cooldown": 0,
"item0": 50,
"item1": 212,
"item2": 164,
"item3": 0,
"item4": 152,
"item5": 0,
"respawn_timer": 0,
"position_x": -269.95425415039062,
"position_y": -252.30490112304687,
"net_worth": 8330
},
{
"player_slot": 3,
"account_id": 106519437,
"hero_id": 52,
"kills": 18,
"death": 0,
"assists": 10,
"last_hits": 165,
"denies": 5,
"gold": 4561,
"level": 19,
"gold_per_min": 689,
"xp_per_min": 711,
"ultimate_state": 3,
"ultimate_cooldown": 0,
"item0": 41,
"item1": 254,
"item2": 119,
"item3": 180,
"item4": 121,
"item5": 117,
"respawn_timer": 0,
"position_x": -6237.72802734375,
"position_y": -5858.58349609375,
"net_worth": 18161
},
{
"player_slot": 4,
"account_id": 80316220,
"hero_id": 112,
"kills": 7,
"death": 0,
"assists": 16,
"last_hits": 31,
"denies": 1,
"gold": 782,
"level": 14,
"gold_per_min": 398,
"xp_per_min": 413,
"ultimate_state": 1,
"ultimate_cooldown": 90,
"item0": 100,
"item1": 36,
"item2": 102,
"item3": 46,
"item4": 1,
"item5": 214,
"respawn_timer": 0,
"position_x": -6938.12158203125,
"position_y": -5003.19775390625,
"net_worth": 9697
},
{
"player_slot": 5,
"account_id": 201217135,
"hero_id": 110,
"kills": 3,
"death": 4,
"assists": 11,
"last_hits": 51,
"denies": 6,
"gold": 1624,
"level": 12,
"gold_per_min": 317,
"xp_per_min": 331,
"ultimate_state": 1,
"ultimate_cooldown": 56,
"item0": 214,
"item1": 46,
"item2": 65,
"item3": 36,
"item4": 100,
"item5": 0,
"respawn_timer": 26,
"position_x": -6694.41455078125,
"position_y": -5180.58984375,
"net_worth": 8089
}
]
,
"abilities": [
{
"ability_id": 5023,
"ability_level": 4
},
{
"ability_id": 5024,
"ability_level": 2
},
{
"ability_id": 5025,
"ability_level": 3
},
{
"ability_id": 5026,
"ability_level": 2
}
]
,
"abilities": [
{
"ability_id": 5361,
"ability_level": 4
},
{
"ability_id": 5362,
"ability_level": 4
},
{
"ability_id": 5363,
"ability_level": 1
},
{
"ability_id": 5364,
"ability_level": 2
}
]
,
"abilities": [
{
"ability_id": 5241,
"ability_level": 4
},
{
"ability_id": 5242,
"ability_level": 4
},
{
"ability_id": 5243,
"ability_level": 4
},
{
"ability_id": 5244,
"ability_level": 3
},
{
"ability_id": 5002,
"ability_level": 3
}
]
,
"abilities": [
{
"ability_id": 5651,
"ability_level": 4
},
{
"ability_id": 5652,
"ability_level": 4
},
{
"ability_id": 5653,
"ability_level": 3
},
{
"ability_id": 5654,
"ability_level": 2
}
]
,
"abilities": [
{
"ability_id": 5623,
"ability_level": 4
},
{
"ability_id": 5625,
"ability_level": 4
},
{
"ability_id": 5626,
"ability_level": 2
},
{
"ability_id": 5630,
"ability_level": 2
},
{
"ability_id": 5631,
"ability_level": 4
},
{
"ability_id": 5624,
"ability_level": 4
},
{
"ability_id": 5627,
"ability_level": 2
},
{
"ability_id": 5628,
"ability_level": 2
}
]
}
}
}
I found this in api/leagues. Is there way to filter level of league ? I couldn't figure it out somehow.
TIERS = {
1 => "Amateur",
2 => "Professional",
3 => "Premier"
}
Thank You!
Hi! I use this code to get the matches, but after 509 API returns the result one match all the time. As a result I could not get matches older than 9 months.Perhaps API has limitations for their old matches? Anybody know it?
api = Dota.api
@matches = []
last_id = nil
10.times do
unless last_id.nil?
matches = api.matches(player_id: player_id, after: last_id)
last_id = matches.last.id
else
matches = api.matches(player_id: player_id)
end
last_id = matches.last.id
@matches += matches
end
When I get the results older then ID 983477424, I get it
https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/V001/?start_at_match_id=983477424&key=&account_id=
{
"result": {
"status": 1,
"num_results": 1,
"total_results": 500,
"results_remaining": 0,
"matches": [
{
"match_id": 983477424,
"match_seq_num": 880040655,
"start_time": 1414274046,
"lobby_type": 0,
"radiant_team_id": 0,
"dire_team_id": 0,
"players": [
{
"account_id": 10210815,
"player_slot": 0,
"hero_id": 10
},
{
"account_id": 135009706,
"player_slot": 1,
"hero_id": 90
},
{
"account_id": 4294967295,
"player_slot": 2,
"hero_id": 34
},
{
"account_id": 52312630,
"player_slot": 3,
"hero_id": 105
},
{
"account_id": 41823129,
"player_slot": 4,
"hero_id": 65
},
{
"account_id": 115639012,
"player_slot": 128,
"hero_id": 74
},
{
"account_id": 4294967295,
"player_slot": 129,
"hero_id": 71
},
{
"account_id": 23521528,
"player_slot": 130,
"hero_id": 41
},
{
"account_id": 78839963,
"player_slot": 131,
"hero_id": 44
},
{
"account_id": 37245194,
"player_slot": 132,
"hero_id": 86
}
]
}
]
}
}
Underlord's abilities have been added to ability.yml but he has not been added to hero.yml
Hello,
First thanks for gem.
I've error in
/home/tugsbayar/.rvm/gems/ruby-2.2.2/gems/dota-0.0.19/lib/dota/api/live_match.rb:48:in `raw_side'
when I tried to get dire from live_match.
There's dire and radiant in raw view...
How can I fix it ?
Line 103 in 55c0033
Hi!
Retrieving history of leveled abilities fails now cause of missing ability ids from new talent system added in patch 7.00. I want to update /data/ability.yml according to patch 7.00. But I stuck on finding a simple way to do it. How did you create this file initially?
>> p.hero
NoMethodError: undefined method `[]' for nil:NilClass
from /Library/Ruby/Gems/2.0.0/gems/dota-0.0.18/lib/dota/api/hero.rb:10:in `initialize'
from /Library/Ruby/Gems/2.0.0/gems/dota-0.0.18/lib/dota/api/basic_player.rb:28:in `new'
from /Library/Ruby/Gems/2.0.0/gems/dota-0.0.18/lib/dota/api/basic_player.rb:28:in `hero'
from /Users/michael.snowden/RoR/dota2/app/views/matches/show.html.haml:8:in `block in _app_views_matches_show_html_haml__790562918000300060_70277494873540'
Also, I can't access the mapping:
>> Dota::API::Hero::MAPPING
NoMethodError: undefined method `[]' for nil:NilClass
from /Library/Ruby/Gems/2.0.0/gems/dota-0.0.18/lib/dota/api/hero.rb:10:in `initialize'
from /Library/Ruby/Gems/2.0.0/gems/dota-0.0.18/lib/dota/api/basic_player.rb:28:in `new'
from /Library/Ruby/Gems/2.0.0/gems/dota-0.0.18/lib/dota/api/basic_player.rb:28:in `hero'
from /Users/michael.snowden/RoR/dota2/app/views/matches/show.html.haml:8:in `block in _app_views_matches_show_html_haml__790562918000300060_70277494873540'
However, I see the mapping file under /Library/Ruby/Gems/2.0.0/gems/dota-0.0.18/lib/dota/utils/mapped.rb
.
This is preventing me from accessing the hero a player uses, such as player.hero
. However, I can still access heroes without players, such as Dota.api.heroes(43)
Hi! How about adding https://codeclimate.com to provide some nice info on code and tests? It appears that integrating it with Travis CI requires only one easy step.
Hello once again :)
I've received some feedback on my article and some users were getting 500 error. I've browsed through the logs and seems like the error was here bodrovis/Sitepoint-source@49fc799#diff-38afbfd893e780c8001bb0d8998adcd0L40 So as you see I am just iterating over an array of matches. However sometimes matches
return nil
and therefore calling each
on it made the app crash.
So basically the matches
method
Line 39 in 8f12d56
nil
(because the user has no matches?) - is this an expected behavior? Wouldn't it be better to return an empty array instead?Hello once again.
I am fetching info about a basic All Pick match like this:
match = Dota.api.matches(1325446180)
and then try to get mode id:
match.mode # => nil
match.mode_id # => 22
However there is no such key here:
dota/lib/dota/api/basic_match.rb
Line 18 in b041256
Here is this match on DotaBuff: http://www.dotabuff.com/matches/1325446180
I am doing something wrong or has those ids changed?
Hello.
I want to get item_def field value from league. But there's no field available in League object.
How can I access to the field?
Thanks for help.
Firstly, Huge thanks for this gem.
I just wanted to know how to get abilities for particular hero ?
is there an end point for that?
I don't see hero_id in abilities.
please help me with this :)
Hello!
Recently I've written an article about Dota API that relies heavily on this gem. Maybe you'd like to add a link to that post somewhere in the docs http://www.sitepoint.com/steam-powered-dota-on-rails/
Cheers!
I noticed in the unit tests that an API key is hardcoded. It's probably best to set the API key has an environment variable so people don't store it anywhere in the code.
For example:
Dota.configure do |config|
config.api_key = ENV['DOTA_API_KEY']
end
This option has a confusing description - it does not return match IDs equal or greater than this. On the contrary, it returns match IDs equal or smaller than this.
https://wiki.teamfortress.com/wiki/WebAPI/GetMatchHistory - this wiki explains it right: "Start searching for matches equal to or older than this match ID."
Or you can try it with my example:
Dota.api.matches(player_id: 454215083, after: 3397884924).map(&:id)
=> [3397906921, 3397884924, 3397325005, 3397310018, 3397249302, 3395653392, 3395006949, 3394906999, 3394782080, 3394657020, 3394585777, 3394520695]
Dota.api.matches(player_id: 454215083, after: 3397884924).count
=> 11
Dota.api.matches(player_id: 454215083, after: 3394585777).count
=> 2
Oh, the builds are now passing! How did you manage to fix that after all?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.