beinando
beinando

Reputation: 497

Some questions about Valve's Steam Web API - Fetching Dota 2 Match History

I wanted to write a little program to analyse the Dota 2 matches in order to program a Hero Picking Tool. If there will be some machine learning, is still up to decide for me

I just checked out the Steam Web API documentation and wrote a little program to get Data and write it in a file, but I have an issue with the commands GetMatchHistoryBySequenceNum and GetMatchHistory, so I have two questions about that.

  1. I used the this "command" to get a list of games: https‍://api.steampowered.com/IDOTA2Match_205790/GetMatchHistoryBySequenceNum/v1/?key=..my key

    What does IDOTA2Match_205790 mean? There is also a version of this command, using IDOTA2Match_570, where I get different results. What does IDOTA2Match_ID do? I never found anything about this.

  2. Somehow, the parameter start_at_match_seq_num does not work. I always get the same results. I know I need the sequence id instead of the match id, but the sequence id is a number in between 0 and 100 when using GetMatchHistoryBySequenceNum.

  3. Additional information:

    I want to use GetMatchHistoryBySequenceNum instead of GetMatchHistory because GetMatchHistory shows weird behaviour: It returns you the latest finished games, ordered by the starting time, not the finishing time. This is extremely unsuited, because it returns you many games with game length under 10 minutes, and rarely games over 30 minutes.

    (For Dota players) I think (I have the suspicion) that this is also the reason why websites like dotapicker.com seem to favor undying and other early game heroes.

My code is here:

for($pages = 0 ; $pages<3; $pages++){

    for ($x = 0; $x <= 100; $x++){

        if(strpos($homepage, "match_id", $offset+10)==false){   
            break;
        }

        $match_id_str = "";
        $index1  = strpos($homepage, "match_id", $offset+10);
        $offset = $index1;

        #10 to 16: this is the letters after the search-word "match_id"  (the actual number)
        for ($x = 10; $x <= 16; $x++) {
            $match_id_str = $match_id_str.$homepage[$index1+$x];
        }

    }

    $cmd_url  = "https://api.steampowered.com/IDOTA2Match_205790/GetMatchHistoryBySequenceNum/v1/?key=My_key&start_at_match_seq_num=".match_id_str;
    $homepage = file_get_contents($cmd_url);
    file_put_contents($file, $homepage, FILE_APPEND);
}

I know this is kind of a niche topic, but this is also the reason why it is so hard to find information about it.

Upvotes: 4

Views: 7412

Answers (2)

jdlau
jdlau

Reputation: 1

I get the 570 from http://api.steampowered.com/ISteamApps/GetAppList/v2

...
{"appid":570,"name":"Dota 2"}
...
{"appid":205790,"name":"Dota 2 Test"}

So I think the is the game's appid.

Upvotes: 0

Ralfizzle
Ralfizzle

Reputation: 517

Late to the party, but I will answer in case anyone else sees this post.

First Part

From https://dev.dota2.com/showthread.php?t=58317:

If you are developing your actual dynamic API calls, (first make sure you have implemented a suitable request limit as above) consider using the Dota2 Beta TEST API, which works identically to the Dota2 Beta API, except its urls are different:

Replace "IDOTA2Match_570" with "IDOTA2Match_205790"

Second Part

start_at_match_seq_num requires the actual sequence ID of the match. You can use the GetMatchDetails endpoint to get the sequence number of a particular match.

https://wiki.teamfortress.com/wiki/WebAPI/GetMatchDetails

The sequence number will be listed in the response object as match_seq_num.

Upvotes: 2

Related Questions