DOTA 2 Match History WebAPI(翻译)

关于DOTA 2 Match History WebAPI 的 源网页地址: http://dev.dota2.com/showthread.php?t=47115php

因为源网页全英文,这边作下翻译方便之后本身及他人查阅(若有翻译不正确的地方请指正):api

DOTA2如今提供匹配记录的WebAPI.。Web开发者如今能够以JSON或者XML格式,得到匹配历史记录及详情并使用在他们本身的应用中。 

首先登陆 http://steamcommunity.com/dev/apikey ,你将得到你的API惟一密钥,请不要在作WebAPI请求的时候泄露或被其余人查看到

如下是两个获取DOTA2匹配历史记录的API:安全

 

得到匹配历史记录:服务器

https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/V001/?key=<key>

将<key> 替换成你本身的API密钥,这样就会以JSON形式获得最新的25场公开匹配,你也能够要求以XML格式返回经过:app

https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/V001/?format=XML&key=<key>

得到最新的25场匹配. 若是想要得到更早的25场匹配记录, 请使用字段 "start_at_match_id" ,将你得到的一个match_id填入其中:(即获取以match_id做为最新一场的25场匹配历史记录)ide

https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/V001/?start_at_match_id=<match_id>&key=<key>

若是想要获取匹配的具体内容,使用这个API:post

https://api.steampowered.com/IDOTA2Match_570/GetMatchDetails/V001/?match_id=<match_id>&key=<key>

接下来额外的字段也可使用在获取匹配历史记录:网站

player_name=<name> # 经过玩家名字搜索匹配, 仅限精确匹配
hero_id=<id> # 经过特定的英雄搜索, 英雄的ID在你的DOTA安装目录 dota/scripts/npc/npc_heroes.txt 中
skill=<skill>  # 0为任意 , 1为N , 2为H, 3为VH
date_min=<date> # date in UTC seconds since Jan 1, 1970 (unix time format)
date_max=<date> # date in UTC seconds since Jan 1, 1970 (unix time format)
account_id=<id> # Steam帐号ID (不是Steam的登陆ID, 而是数字ID)
league_id=<id> # 该联赛ID的比赛记录
start_at_match_id=<id> # 从填入的匹配记录ID开始,降序
matches_requested=<n> # 默认25场,能够改低

举个例子,得到最新的一场匹配记录:this

https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/V001/?matches_requested=1&key=<key>

一块儿来探讨这个功能吧. 咱们火烧眉毛的想要看到人们想出如何使用这些信息。

Please do be nice and not slam the WebAPI’s too heavily, however! Thanks!spa


关于WebAPI比较常常被问到的问题:

我如何根据GetMatchDetails的信息得到录像?
Replays由下面的URL组成:

http://replay<cluster>.valve.net/570/<match_id>_<replay_salt>.dem.bz2

其中 cluster, match_id 和 replay_salt 能够在GetMatchDetails中获得. 若是你好奇cluster是什么, 这是指该匹配所在的游戏服务器数据中心.

是否能够经过API得到非公开匹配的匹配记录和详情?
目前不能够. 咱们正在寻找一个可能的OATUH认证系统,在可以保证玩家帐号安全的状况下获取他们的匹配记录,并提供给第三方网站获取。咱们但愿有更多的相关信息尽快公布。

我该如何找到hero_id和item所对应的英雄和物品?
这些对应能够在你的DOTA2安装目录下被找到。
英雄:
Steam/steamapps/common/dota 2 beta/gamedota/scripts/npc/npc_heroes.txt
物品:
Steam/steamapps/common/dota 2 beta/gamedota/scripts/npc/items.txt

是否有正在进行的比赛的WebAPI?
尚未,但这真是个绝佳的想法

关于API调用次数是否有限制呢?
目前没有,可是若是匹配服务器正忙或者你频繁调用超出限制,你将可能得到503错误。请等待30秒而后重试。 由于在API开放上有个很好的经验法则就是,限制你每秒发送的请求。

来自DOTA2开发团队的更新(应该是关于当时天梯事件,然后关闭了API一段时间的通知,懒得翻了。。。)
你们注意,WebAPI如今没法访问。 What happened was that we were seeing such an overwhelming demand from people for this information that our servers were getting completely bogged down servicing all of these requests. None of the behavior we saw was malicious, there was just way too much demand and unfortunately it really started impacting the experience of general DOTA players and therefore we had to disable it for now. This is of course super interesting information and we want to make it as available to as many people as we possibly can and we are working on a couple of solutions to help greatly improve the situation so we can handle more requests, but can’t give any definitive time frame for when these will be brought online. We will keep you posted as things develop, but hopefully our solutions will let us have our cake and eat it too (after all not all cakes are a lie). 

As a side note though, if people are developing against this API, make sure to implement rate limiting within your systems. We don’t have any numbers at this point, but we of course need to prevent individual accounts from submitting thousands of requests in a small window so that we can make sure that we can handle a reasonable number of users. Also if people have specific queries that they are running in large quantities that don’t naturally fit into the existing API let us know so that if it is a common request people have that the system can efficiently handle those requests.

相关文章
相关标签/搜索