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

Python interface to the stats API

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Python interface to the stats API

    Not sure if this is the right section, but there's threads about a stats site here so I guess it fits.

    I made a simple Python library for the Dota 2 stats API. It's a bit unpolished and not documented all that well, but I would improve it if anyone is interested.

    Basic instructions:
    1. Put your API Key in d2slib.py
    2. Run generateHeroList.py to generate a list of heroes and hero IDs
    3. Look at the example scripts included (playerSkillReport and test) to see how to use the functions in d2slib.py


    Download:
    https://mega.co.nz/#!jA9QmRIR!Tjs1VX...vxpsBFbX_s3nRs




    Changelog:
    2012/08/10: Bugfixes, shouldn't choke up on bot games as much
    2012/08/19: More bugfixes, rate limiter works correctly now, internal changes to playerSkillReport
    2013/10/09: Python 3 compatibility, fixed issues with new API
    Attached Files
    Last edited by winxp; 10-09-2013, 12:04 AM.
    Steam Profile
    Python Interface to the Stats API
    Suggestion: Courier Shift-Queue Improvements
    Make Disablehelp work on Decrepify
    Useful link for mute system supporters

  • #2
    Originally posted by winxp View Post
    Not sure if this is the right section, but there's threads about a stats site here so I guess it fits.

    I made a simple Python library for the Dota 2 stats API. It's a bit unpolished and not documented all that well, but I would improve it if anyone is interested.

    Basic instructions:
    1. Put your API Key in d2slib.py
    2. Run generateHeroList.py to generate a list of heroes and hero IDs
    3. Look at the example scripts included (playerSkillReport and test) to see how to use the functions in d2slib.py

    [ATTACH]8524[/ATTACH]
    I taught myself python to use this API and my code does pretty much what yours does... apart from the skill level generation.
    Good to know I'm doing something right.

    Not sure if the 1 request per second is neccesary though, I've been working without any limitation for a while and haven't run into any problems.

    Comment


    • #3
      Originally posted by Acren View Post
      Not sure if the 1 request per second is neccesary though, I've been working without any limitation for a while and haven't run into any problems.
      It's not that you'll run into problems, more of just that valve doesn't want excessive load on the servers. However it does make the playerSkillReport.py take about 30 seconds alone on waiting between requests since it has to do 4 match history lookups and 25 game detail lookups.

      If anyone is wondering what the example program can do, it can be used to generate a summary of someone's recent games with skill level. Useful for quickly determining someone's overall skill:
      skillreport.JPG
      Steam Profile
      Python Interface to the Stats API
      Suggestion: Courier Shift-Queue Improvements
      Make Disablehelp work on Decrepify
      Useful link for mute system supporters

      Comment


      • #4
        I get an error when running through 3.2 IDLE

        SyntaxError
        invalid syntax (generateHeroList.py, line 18) C:\Users\xxx\Desktop\d2slib\generateHeroList.py 18
        Last edited by Dethgar; 08-25-2012, 12:50 AM.

        Comment


        • #5
          Works for me. Are you sure you put your key in?

          Also what python version are you using?
          Steam Profile
          Python Interface to the Stats API
          Suggestion: Courier Shift-Queue Improvements
          Make Disablehelp work on Decrepify
          Useful link for mute system supporters

          Comment


          • #6
            if stuff like this exists, why doesn't valve just make the rankings public?
            Never underestimate the power of the masses.

            Comment


            • #7
              Yes, and I'm using 3.2

              Comment


              • #8
                Oh, I guess Python 3 changed print from a statement to a function. I'll upload a new one later today. In the meantime if you really need to use it just find every "print blah" and change it to "print(blah)".
                Steam Profile
                Python Interface to the Stats API
                Suggestion: Courier Shift-Queue Improvements
                Make Disablehelp work on Decrepify
                Useful link for mute system supporters

                Comment


                • #9
                  Hey i am currently searching for a bug in the Captainsmode Slot distribution and i need to find all my gameidĀ“s of captainsmode games.
                  Is there any way to modify your tool so it shows the gamemodes aswell?

                  greetings

                  Comment


                  • #10
                    Originally posted by ranaki View Post
                    if stuff like this exists, why doesn't valve just make the rankings public?
                    Wondering the same thing.
                    Originally posted by Shibubu
                    Sure, it looks a bit silly, but this helmet makes more sense than ~50% of Furions cosmetics that are already in the game. And its not like he's wielding a wooden penis (one can easily make a penis shaped staff out of wooden branch and there are no arguments why it could not be done). The Acorn helmet is actually VERY fitting since it's natural shape is used. Also it is used for it's quality to withstand blows.
                    Wow, amazing insight.

                    Comment


                    • #11
                      PM.

                      Comment


                      • #12
                        I'm running into an error when running playerskillreport it seems to not like parsing through match results and has an index error: List out of range at

                        If matchtypes[index] == 0

                        Comment


                        • #13
                          This belongs in the WebAPI section. http://dev.dota2.com/forumdisplay.php?f=411

                          Comment


                          • #14
                            Originally posted by jimmydorry View Post
                            This belongs in the WebAPI section. http://dev.dota2.com/forumdisplay.php?f=411
                            Well I'm sure he is aware of that by now. It's only been months.

                            Comment

                            Working...
                            X