Announcement

Collapse

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

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

  • Originally posted by IceHaku View Post
    Just a curiosity, using the php date function I had this problem:

    $match_url_xml->starttime value at this point is: 1343015861

    date("d-M-Y", ($match_url_xml->starttime)
    Warning: date() expects parameter 2 to be long, string given in
    The reason that happens is because (as far as I know) the xml parser can't tell the difference between numbers and strings, so it just makes everything a string.
    If you use php's json decoder, it's able to tell that the date is a number and then inside the object it returns it stores data in the correct format.

    If I were you I'd switch to using json over xml. I prefer it because I think its easier on my eyes. And unless Im mistaken I think there's not as many redundant data (that comes from xml's need to open and close with a name) which means there's less data to fetch (someone correct me if I'm wrong here. But I'd say that's why its the default way the api sends data.)
    The API Bible: Things You Should Know Before Starting API Development

    Comment


    • No more reverse engineering !

      Thanks

      Comment


      • Hello guys.

        I took all the items and made a JSON file containing the id and name of each item. I also converted all the item images to a 40x30px format with the correct item names. This should solve all problems item related
        Now if only someone would add the localized item names to the JSON file, it would be perfect

        I also made a PHP function that makes it easy to get the name for the corresponding item id. You can then just simply call the function and use it to construct an image url, like shown below.

        The function:

        PHP Code:
        function getItem($item_id){
            
        $json_output json_decode(file_get_contents('items.json'))->result;
            
            foreach (
        $json_output->items as $item){
                if (
        $item->id == $item_id){
                    
        $name $item->name;
                }
            }
            
            if (
        $name == ''){
                
        $name 'emptyitembg';
            }

            if (
        strpos($name'recipe') !== false){
                
        $name 'recipe';
            }
            
            return 
        $name;

        Example image code:

        HTML Code:
        <img src="images/items/<?=getItem($player->item_0);?>.png"/>
        I have added a zip file with the JSON file and the images to this post.

        If you want to see it in action, here you go: http://dota-2.dk/matches/match.php?matchid=27081284

        UPDATE 1:
        Updated the item icons with the new ones, and updated the function so it shows recipes correctly.
        Attached Files
        Last edited by Lazze; 07-27-2012, 12:11 PM.

        Comment


        • Originally posted by Lazze View Post
          Hello guys.

          I took all the items and made a JSON file containing the id and name of each item. I also converted all the item images to a 40x30px format with the correct item names. This should solve all problems item related
          Now if only someone would add the localized item names to the JSON file, it would be perfect

          I also made a PHP function that makes it easy to get the name for the corresponding item id. You can then just simply call the function and use it to construct an image url, like shown below.

          The function:

          PHP Code:
          function getItem($item_id){
              
          $json_output json_decode(file_get_contents('items.json'))->result;
              
              foreach (
          $json_output->items as $item){
                  if (
          $item->id == $item_id){
                      
          $name $item->name;
                  }
              }
              
              if (
          $name == ''){
                  
          $name 'emptyitembg';
              }
              
              return 
          $name;

          Example image code:

          HTML Code:
          <img src="images/items/<?=getItem($player->item_0);?>.png"/>
          I have added a zip file with the JSON file and the images to this post.

          If you want to see it in action, here you go: http://dota-2.dk/matches/match.php?matchid=27081284
          Nice work. Where were you yesterday? As you can see i also recently created Item Lists and uploaded the images, but not mapped directly like you did

          Thanks

          Comment


          • Syllabear often has most of his items on the bear - but even in the detailed match view this information isn't available - can it be added in?

            Comment


            • I find it extremely awkward to crawl GetMatchHistory.

              I see no method for determining how to cleanly chain into the next chunk of 500 matches. You can't assume that the lowest start_time is your new date_max because the results are presumably ordered by end_time, which is not provided.

              The only method that I can see is to continually request a smaller date range (date_max to date_min) until you get less than 500 matches, and then use the smallest start_time as your new date_max.

              Is there some obvious method that I am missing?

              Comment


              • Originally posted by walkingcarpet View Post
                I find it extremely awkward to crawl GetMatchHistory.

                I see no method for determining how to cleanly chain into the next chunk of 500 matches. You can't assume that the lowest start_time is your new date_max because the results are presumably ordered by end_time, which is not provided.

                The only method that I can see is to continually request a smaller date range (date_max to date_min) until you get less than 500 matches, and then use the smallest start_time as your new date_max.

                Is there some obvious method that I am missing?
                It's ordered by match_id which is created in chronological order, so date_max would work fine for traversing. However, note that it's possible that two or more matches start at the same time, so you would want to filter by smallest start_time + 1 for subsequent requests then removing the duplicates based on match_id. There's actually start_at_match_id for this purpose, though there was some kind of bug that prevents you from traversing past the first 500 matches, but anyway Zoid has already mentioned that he'll be fixing it by this week.
                Last edited by Alesix; 07-25-2012, 12:18 PM.

                Comment


                • Originally posted by Alesix View Post
                  It's ordered by match_id which is created in chronological order, so date_max would work fine for traversing. However, note that it's possible that two or more matches start at the same time, so you would want to filter by smallest start_time + 1 for subsequent requests then removing the duplicates based on match_id. There's actually start_at_match_id for this purpose, though there was some kind of bug that prevents you from traversing past the first 500 matches, but anyway Zoid has already mentioned that he'll be fixing it by this week.
                  edit: Thought they were non-sequential but it appears they are simply non-contiguous, likely due to private matches and or bot games.

                  However you mention the start_at_match_id change posted by Zoid which I somehow missed, and that addresses my post completely, so thank you.
                  Last edited by walkingcarpet; 07-25-2012, 01:02 PM. Reason: corrected my claim that match_ids are non sequential

                  Comment


                  • A quick question: Is there any way I can tell whether a match is counted where there's a leaver in it?

                    Comment


                    • Originally posted by Alesix View Post
                      A quick question: Is there any way I can tell whether a match is counted where there's a leaver in it?
                      Yes. The match details contain a string for each player called leaver_status. If this is 1, the player left.

                      Comment


                      • Originally posted by Lazze View Post
                        Yes. The match details contain a string for each player called leaver_status. If this is 1, the player left.
                        I know that actually (and by the way, a player is considered to have abandoned the game when the value is 5, not 1). What I'm asking is whether it is possible to tell that a match is actually counted for the remaining players in terms of wins and losses.

                        Comment


                        • Would it be possible to add the bans to info for captain mode games? Would make keeping track of the amount picked/banned so much easier.

                          Comment


                          • Zoid, when u planned to add practice matches too?

                            Comment


                            • practice matches are able to access but will not if version is tournament ...
                              sorry for my bad English ...

                              From Vietnam with Love - Lagest DOTA 2 Community in Vietnam: DotA-2.Vn

                              Comment


                              • Just a quick tip for everyone: The difference in value between account_id and SteamID is 76561197960265728 (which is 2^56 + 2^52 + 2^32). For example, my SteamID is 76561198055198692, and my account_id would be 76561198055198692 - 76561197960265728 = 94932964. This only works for normal user accounts though (as opposed to, say, dev accounts), but I haven't encountered any exceptions so far. And of course, if the language you're using supports 64-bit integers, you can simply perform a modulo 2^32 to extract the account_id.

                                If you're using PHP, take note that unless you're running on 64-bit (both hardware and interpreter), you would need a library which supports arbitary precision (e.g. BC Math) to perform mathematical calculations on 64-bit integers (which SteamIDs are).

                                Comment

                                Working...
                                X