Forum Rules

  • No flaming or derogatory remarks, directly or through insinuation.
  • No discussion, sharing or referencing illegal software such as hacks, keygen, cracks and pirated software.
  • No offensive contents, including but not limited to, racism, gore or pornography.
  • No excessive spam/meme, i.e. copious one liners in a short period of time, typing with all caps or posting meme responses (text/image).
  • No trolling, including but not limited to, flame incitation, user provocation or false information distribution.
  • No link spamming or signature advertisements for content not specific to Dota 2.
  • No Dota 2 key requests, sell, trade etc.
  • You may not create multiple accounts for any purpose, including ban evasion, unless expressly permitted by a moderator.

  • Please search before posting. One thread per issue. Do not create another thread if there is an existing one already.
  • Before posting anything, make sure you check out all sticky threads (e.g., this). Do not create new threads about closed ones.
  • It is extremely important that you post in correct forum section.

  • Balance discussion only in Misc.
  • All art related (such as hero model) feedbacks go to Art Feedback Forum.
  • All matchmaking feedback should go here: Matchmaking Feedback
  • All report/low priority issues should go here: Commend/Report/Ban Feedback
  • No specific workshop item feedback. These should go to workshop page of that item.
  • When posting in non-bugs section (such as this), use [Bugs], [Discussion] or [Suggestion] prefix in your thread name.

In case you object some action by a moderator, please contact him directly through PM and explain your concerns politely. If you are still unable to resolve the issue, contact an administrator. Do not drag these issues in public.

All rules are meant to augment common sense, please use them when not conflicted with aforementioned policies.
See more
See less

Dota 2 Match History WebAPI

This is a sticky topic.
  • Filter
  • Time
  • Show
Clear All
new posts

  • #31
    Yea, that makes a lot more sense. But, still no real output. This I got back:

    array(21) {
      string(238) ""
      string(23) "text/xml; charset=UTF-8"
      array(0) {
    string(222) "<?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE result>
    Still no usable result. Anyone got this to work at all?

    Also this is the url which should work anyway but it isn't:
    Last edited by radonthetyrant; 07-19-2012, 12:09 AM.


    • #32
      Originally posted by Drkirby View Post
      How does the tower status work? Do you turn the number into binary, and each digit corresponds if a tower is up or down?
      That was my first inclination as well. Which values go to which towers is something I haven't figured out yet. (Then again, I haven't tried)

      Here's an XML excerpt retrieved for match ID 691926:
      Forgive my speculation here, as I haven't verified any of this, but once you've converted the relevant values to binary, you end up with something a bit like this:
      Note: I padded the <tower_status_radiant> element value with leading zeroes to match the length of the <tower_status_dire> element. (I justified it by stating that both teams have the same number of buildings, so the length of both these values should be the same.

      Seeing as how each team has three towers in each lane, as well as two towers surrounding their Ancient (giving a total tower count of 11) it seems to coincide with the length of the binary string, as it also has a length of 11. The same principle can be applied to the barracks, as each team has a total of six of them, and the length of the binary strings in those fields just happens to share a length of six characters.

      The next question is: which bits represents which buildings?


      • #33
        For example:
        Account_id = 42417985

        U need do: DEC to BIN and got 10100001110011111101000001
        Add this to begin: 1000100000000000000000001
        And add 0 between this numbers, until u got 57 numbers, so it will be:
        1000100000000000000000001 000000 10100001110011111101000001
        Later do BIN to DEC and u got profile number: 76561198002683713


        • #34
          Originally posted by radonthetyrant View Post
          Yea, that makes a lot more sense. But, still no real output. This I got back:

          Still no usable result. Anyone got this to work at all?

          Also this is the url which should work anyway but it isn't:
          In your Steam Games Library, you should have two entries for DOTA2:

          Dota 2 [AppID: 570]
          Dota 2 Test [AppID: 205790]

          The API call you are making is for the AppID of 205790, which isn't the Dota 2 game that most of us are playing. The result that you're getting back seems to indicate that you haven't played any matches in that version.

          In the next update for the mainstream Dota 2 client, they're adding WebAPI support (at which point you can just find/replace "205790" with "570" and everything should work just fine).

          Until then, you can write code and test it against this API so that you're ready when patch day rolls around!


          • #35
            Damn how can I be so blind

            Thanks that seems to be solved now


            • #36
              Here's a quick C# enum I wrote (but haven't checked thoroughly, so excuse any errors I may have made) of the heroes and their HeroID values, to save people some time of typing it out themselves.

              public enum Hero
              	AntiMage = 1,
              	Axe = 2,
              	Bane = 3,
              	Bloodseeker = 4,
              	CrystalMaiden = 5,
              	DrowRanger = 6,
              	Earthshaker = 7,
              	Juggernaut = 8,
              	Mirana = 9,
              	Morphling = 10,
              	Nevermore = 11,
              	PhantomLancer = 12,
              	Puck = 13,
              	Pudge = 14,
              	Razor = 15,
              	SandKing = 16,
              	StormSpirit = 17,
              	Sven = 18,
              	Tiny = 19,
              	VengefulSpirit = 20,
              	Windrunner = 21,
              	Zeus = 22,
              	Kunkka = 23,
              	Lina = 25,
              	Lion = 26,
              	ShadowShaman = 27,
              	Slardar = 28,
              	Tidehunter = 29,
              	WitchDoctor = 30,
              	Lich = 31,
              	Riki = 32,
              	Enigma = 33,
              	Tinker = 34,
              	Sniper = 35,
              	Necrolyte = 36,
              	Warlock = 37,
              	Beastmaster = 38,
              	QueenOfPain = 39,
              	Venomancer = 40,
              	FacelessVoid = 41,
              	SkeletonKing = 42,
              	DeathProphet = 43,
              	PhantomAssassin = 44,
              	Pugna = 45,
              	TemplarAssassin = 46,
              	Viper = 47,
              	Luna = 48,
              	DragonKnight = 49,
              	Dazzle = 50,
              	Rattletrap = 51, Clockwerk = 51, // Listed in the file as Rattletrap, but is called Clockwerk in game.
              	Leshrac = 52,
              	Furion = 53, NaturesProphet = 53, // Listed in the file as Furion, but is called Nature's Prophet in game.
              	Lifestealer = 54,
              	DarkSeer = 55,
              	Clinkz = 56,
              	Omniknight = 57,
              	Enchantress = 58,
              	Huskar = 59,
              	NightStalker = 60,
              	Broodmother = 61,
              	BountyHunter = 62,
              	Weaver = 63,
              	Jakiro = 64,
              	Batrider = 65,
              	Chen = 66,
              	Spectre = 67,
              	AncientApparition = 68,
              	DoomBringer = 69,
              	Ursa = 70,
              	SpiritBreaker = 71,
              	Gyrocopter = 72,
              	Alchemist = 73,
              	Invoker = 74,
              	Silencer = 75,
              	ObsidianDestroyer = 76,
              	Lycan = 77,
              	Brewmaster = 78,
              	ShadowDemon = 79,
              	LoneDruid = 80,
              	ChaosKnight = 81,
              	Meepo = 82,
              	TreantProtector = 83,
              	OgreMagi = 84,
              	Undying = 85,
              	Rubick = 86,
              	Disruptor = 87,
              	NyxAssassin = 88,
              	NagaSiren = 89,
              	KeeperOfTheLight = 90,
              	Wisp = 91,
              	Visage = 92,
              A quick tip for those unaware, you can get the name associated with any enumerated value like so:

              String heroName = Enum.GetName(typeof (Hero), int.Parse("integer value of hero ID goes here"));
              It's rudimentary at best because you can't have spaces or punctuation in the names of enumerated values, but it helps for outputting this data for debugging purposes, at least.

              One last thing: you can forgo the int.Parse if you simply specify an integer to begin with, but I wanted it to be as clear as possible.


              • #37
                Zoid, have you considered exposing the player's match making rating with that interface ?


                • #38
                  For any .NET developers wanting an easy way to get the API responses into a strongly typed object, I would encourage them to look into the XSD.EXE utility provided by Microsoft for generating class definitions directly from XML documents.


                  To provide an example of how useful this can be, I have attached a text document (Actually a C# class file with a .txt file extension so be sure to change the file extension if you want to use it) of the auto-generated class file created from the result of the GetMatchDetails API call.

                  I made a few minor alterations to the definition; mainly renaming the class and updating the ElementName attribute in the class decorations for easier/cleaner implementation. Before anyone calls me out on editing an automatically generated piece of code, I kept my modifications to an absolute minimum, my only changes were to change the name of the class so that additional classes could be generated as well; the root element of the XML response is "result" and having that as a class name is rather confusing, I believe.

                  Attachment: MatchDetail.cs.txt

                  To deserialize the XML response directly into an instance of this class, you can use the following snippit of code. It uses generics so this same method can be used to deserialize anything; assuming your input is valid, of course.

                  public static T Deserialize<T>(string xml) where T : new()
                  	var obj = new T();
                  	var read = new StringReader(xml);
                  	var serializer = new System.Xml.Serialization.XmlSerializer(obj.GetType());
                  	XmlReader reader = new XmlTextReader(read);
                  	obj = (T)serializer.Deserialize(reader);
                  	return obj;


                  • #39
                    Rychard, do u know, how to get public enum Items? Just where i can find, where ID items = item?
                    Last edited by Addsky; 07-19-2012, 02:33 AM.


                    • #40
                      Originally posted by Addsky View Post
                      Rychard, do u know, how to get public enum Items?
                      If you're asking about how one might go about getting an enumeration of items (and their associated item IDs of course) then the same process can be followed that I used to create the enumeration for the heroes.

                      In your steam directory a file exists that has a lot of information about the items in the game, most importantly, their names and IDs.

                      This should help you find the file I'm referring to: C:\...<example_path>...\Steam\steamapps\common\dot a 2 beta\dota\scripts\npc\items.txt

                      On my computer, Steam is installed in the root directory of the D:\ drive, so the full file path for me is as follows:

                      D:\Steam\steamapps\common\dota 2 beta\dota\scripts\npc\items.txt
                      Here's a snippit of the first item in that file. The parts that you're likely interested in is the name (in this example, it is "Blink dagger", which is at the beginning between the two lines), and the ID value; in this case, it is "1". This same approach can be used on all the other items in this file to create the enumeration.

                      // Blink dagger
                      	// General
                      	"ID"							"1"														// unique ID number for this item.  Do not change this once established or it will invalidate collected stats.
                      	"AbilityName"					"item_blink"
                      	// Stats
                      	"AbilityCastRange"				"0"
                      	"AbilityCastPoint"				"0.0"
                      	"AbilityCooldown"				"14.0"
                      	"AbilityManaCost"				"75"
                      	// Item Info
                      	"ItemCost"						"2150"
                      	"ItemShopTags"					"teleport"
                      	"ItemQuality"					"component"
                      	"SideShop"						"1"
                      	"InvalidHeroes"					"npc_dota_hero_vengefulspirit;npc_dota_hero_pudge"
                      	// Special	
                      			"var_type"				"FIELD_INTEGER"
                      			"blink_range"			"1200"
                      			"var_type"				"FIELD_INTEGER"
                      			"blink_damage_cooldown"	"3"
                      			"var_type"				"FIELD_INTEGER"
                      			"blink_range_clamp"	"960"

                      Sorry that I haven't gotten around to this personally, but its on my list of things to do.


                      • #41
                        But on heroes, u can go here and got list of items, so i wanna find same API for items? Someone know it?


                        • #42
                          Theres a way to call the API without a web application? I want to play around with scripts in Python, but don't have a website/domain for it.


                          • #43
                            Cool, I'll definitely be putting this to use. Thanks heaps!

                            Is there any way to get hero and item images without hacking the Dota 2 client to pieces; and on GetHeroes, what does the itemizedonly boolean do? It doesn't seem to change the output.


                            • #44
                              I would really like that feature for private matches. Since the beginning I am searching for a possibility to track my team's stats for certain heroes and indivdual comparison. Keep going!


                              • #45
                                Zoid, can u make API for practice match also? It's more important...
                                Last edited by Addsky; 07-19-2012, 05:57 AM.