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.

相關文章
相關標籤/搜索