dota2py

Python tools for Dota 2

Web API client

A thin wrapper around the Dota 2 WebAPI described (http://dev.dota2.com/showthread.php?t=47115)

This uses either the requests library (dota2py/api.py), or Twisted (dota2py/twisted/api.py)

To use the Web API you must have a valid steam API key. You can get one at http://steamcommunity.com/dev/apikey

More information about the API can be found in this thread and in the WebAPI dev forums

WebAPI examples:

Examples code for both the standard and Twisted APIs can be found in the examples folder.

Find the latest match for a player

# Get all the most recent match played by the player 'acidfoo'
account_id = int(api.get_steam_id("acidfoo")["response"]["steamid"])

# Get a list of recent matches for the player
matches = api.get_match_history(account_id=account_id)["result"]["matches"]

# Get the full details for a match
match = api.get_match_details(matches[0]["match_id"])

Replay Parser

This contains a Python port of demoinfo2, but will probably be expanded into more useful tools for Dota 2 replays You will need snappy and Google Protocol Buffers installed

To run the parser either run parser.py or in Linux use the dota2py_parser script

To show a summary of useful information from a replay, run summary.py or dota2py_summary (this functionality is a work in progress)

Installation

Install via pip:

$ pip install dota2py

or, install via easy_install:

$ easy_install dota2py

Running the tests

There are a number of functional tests for the Web API. To run the tests you must set the environment variable DOTA2_API_KEY to your key. In windows:

> set DOTA2_API_KEY=YOUR_KEY_HERE

and in linux:

$ export DOTA2_API_KEY=YOUR_KEY_HERE

Once you have set your API key, the easiest way to run the tests is using nosetests (pip install nose).

To run all the tests:

nosetests dota2py

To run a specific test:

nosetests dota2py.funtests.test_api:ApiTest.test_get_steam_id

To print out debug information you can add the following flags:

-v -s --logging-config=debug_logging.cfg


dota2py

Dota 2的Python工具

Web API客户端

描述Dota 2 WebAPI周围的薄型包装( http://dev.dota2.com/showthread.php ?t = 47115 )

这将使用请求库( dota2py / api.py )或 Twisted dota2py/twisted/api.py

要使用Web API,您必须具有有效的Steam API密钥。您可以在 http://steamcommunity.com/dev/apikey 上获得一个

有关API的更多信息,请参见此线程,并在 WebAPI开发论坛

WebAPI示例:

标准和Twisted API的示例代码可以在示例文件夹中找到。

Find the latest match for a player

# Get all the most recent match played by the player 'acidfoo'
account_id = int(api.get_steam_id("acidfoo")["response"]["steamid"])

# Get a list of recent matches for the player matches = api.get_match_history(account_id=account_id)["result"]["matches"]

# Get the full details for a match match = api.get_match_details(matches[0]["match_id"])

Replay Parser

这包含一个 demoinfo2 的Python端口,但可能会扩展为Dota 2重播的更有用的工具 您需要 snappy Google协议缓冲区已安装

要运行解析器运行parser.py或在Linux中使用dota2py_parser脚本

要显示重播中有用信息的摘要,请运行summary.py或dota2py_summary(此功能正在进行中)

安装

通过pip安装:

$ pip install dota2py

或者,通过easy_install进行安装:

$ easy_install dota2py

运行测试

Web API有一些功能测试。要运行测试,您必须将环境变量DOTA2_API_KEY设置为您的密钥。在Windows中:

> set DOTA2_API_KEY=YOUR_KEY_HERE

和linux:

$ export DOTA2_API_KEY=YOUR_KEY_HERE
一旦设置了API密钥,运行测试的最简单的方法是使用nosetests(pip安装鼻子)。

要运行所有测试:

nosetests dota2py

要运行特定测试:

nosetests dota2py.funtests.test_api:ApiTest.test_get_steam_id

要打印出调试信息,您可以添加以下标志:

-v -s –logging-config=debug_logging.cfg




相关问题推荐