这篇文章的源地址:http://dev.dota2.com/showthread.php?t=58317

由于文章内容较多,英语水平有限,准备尝试着以中英混搭的形式翻译,免得曲解一些不懂内容的意思。以下开始为翻译内容:

这篇文章会持续更新, 请在suggesting missing items前查看底部的TODO List

Web开发者现在可以以JSON或者XML格式,获得匹配历史记录及详情并使用在他们自己的应用中。

首先点击这里阅读WebAPI的条款协议

获得密钥

首先登录 http://steamcommunity.com/dev/apikey ,你将获得你的API唯一密钥。

请不要在做WebAPI请求的时候泄露或被其他人查看到。

来自Zoid的说明:

当你到 http://steamcommunity.com/dev/apikey 申请API时,the "domain" field is just a note. 事实上没有任何需要用到的地方, 只是一个 helpful field 让你能够告诉我们你的网站是哪个. 你也可以暂时填入你的名字. 一旦你获得了Key, 这个Key就是当你执行API请求时我们对你的唯一标示。

API请求

提供以下API使用:

(GetMatchHistory)              https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/v001/
(GetMatchDetails) https://api.steampowered.com/IDOTA2Match_570/GetMatchDetails/v001/
(GetHeroes) https://api.steampowered.com/IEconDOTA2_570/GetHeroes/v0001/
(GetPlayerSummaries) https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/
(EconomySchema) https://api.steampowered.com/IEconItems_570/GetSchema/v0001/
(GetLeagueListing) https://api.steampowered.com/IDOTA2Match_570/GetLeagueListing/v0001/
(GetLiveLeagueGames) https://api.steampowered.com/IDOTA2Match_570/GetLiveLeagueGames/v0001/
(GetMatchHistoryBySequenceNum) https://api.steampowered.com/IDOTA2Match_570/GetMatchHistoryBySequenceNum/v0001/
(GetTeamInfoByTeamID) https://api.steampowered.com/IDOTA2Match_570/GetTeamInfoByTeamID/v001/

常用选项:

注意,除非另有说明,否则默认为空或忽略

key=<key>       # Your personal API key (from above)
language=<lang> # The language to retrieve results in (default is en_us) (see http://en.wikipedia.org/wiki/ISO_639-1 for the language codes (first two characters) and http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes for the country codes (last two characters))
format=<form> # The format to retrieve results in ("JSON" or "XML") (default is JSON)

GetMatchHistory
Used to get a list of matches played.

player_name=<name>             # Search matches with a player name, exact match only
hero_id=<id> # Search for matches with a specific hero being played (hero ID, not name, see HEROES below)
game_mode=<mode> # Search for matches of a given mode (see below)
skill=<skill> # 0 for any, 1 for normal, 2 for high, 3 for very high skill (default is 0)
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)
min_players=<count> # the minimum number of players required in the match
account_id=<id> # Search for all matches for the given user (32-bit or 64-bit steam ID)
league_id=<id> # matches for a particular league
start_at_match_id=<id> # Start the search at the indicated match id, descending
matches_requested=<n> # Maximum is 25 matches (default is 25)
tournament_games_only=<string> # set to only show tournament games

例子:

根据某人的32位ID获得其最近的25场比赛

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

获得最近的一场比赛

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

注意,为了能够到”下一页“,你需要做这么一两件事:

  • 使用查询到的最后一场match_id来作为新一次查询的start_at_match_id:
  • https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/V001/?key=<key>&start_at_match_id=<id>&<OTHER_OPTIONS>
  • 使用查询到的最后一场starttime来作为新一次查询的date_max:
  • https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/V001/?key=<key>&date_max=<id>&<OTHER_OPTIONS>

返回结果的字段格式:

  • num_results - 在返回数据中,查询到结果的数量
  • total_results - 这次particular查询到结果的总数[(total_results / num_results) = total_num_pages]
  • results_remaining - 这次查询结果剩余未返回的数量 [(results_remaining / num_results) = remaining_num_pages]
  • matches - 有num_results个数量比赛的数组:
      • match_id - 比赛的数字ID
      • match_seq_num - 比赛序号 - the order in which matches are recorded
      • start_time - date in UTC seconds since Jan 1, 1970 (unix time format)

    lobby_type

      - lobby值的对应关系

      • 5 = Team match.
      • 4 = Co-op with bots.
      • 3 = Tutorial.
      • 2 = Tournament.
      • 1 = Practice.
      • 0 = Public matchmaking.
      • -1 = Invalid.
    • players - 玩家数组:

      • account_id - 玩家的32位Steam ID - 如果玩家将自己的资料设为隐私,account_id将会是"4294967295"
      • player_slot - 8位unsigned int型: if the left-most bit is set, the player was on dire. the two right-most bits represent the player slot (0-4).
      • hero_id - 玩家所玩英雄的数字ID (见下方)

GetMatchDetails

Used to get detailed information about a specified match.

可用的选项:

match_id=<id> # the match's ID

例子:

根据ID "XXXXX"获得比赛详细记录:、

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

返回结果的字段格式:

  • players - 玩家数组
    • account_id - 玩家的32位Steam ID - 如果玩家将自己的资料设为隐私,account_id将会是"4294967295"
    • player_slot - 8位unsigned int型: if the left-most bit is set, the player was on dire. the two right-most bits represent the player slot (0-4).
    • hero_id - 玩家所玩英雄的数字ID
    • item_0 - 比赛结束时玩家的物品栏 左上 物品ID
    • item_1 - 比赛结束时玩家的物品栏 中上 物品ID
    • item_2 - 比赛结束时玩家的物品栏 右上 物品ID
    • item_3 - 比赛结束时玩家的物品栏 左下 物品ID
    • item_4 - 比赛结束时玩家的物品栏 中下 物品ID
    • item_5 - 比赛结束时玩家的物品栏 右下 物品ID
    • kills - 杀人数
    • deaths - 死亡数
    • assists - 助攻数
    • leaver_status
      • NULL - 玩家是电脑
      • 2 - 玩家放弃比赛
      • 1 - 玩家在比赛可以安全退出后放弃比赛
      • 0 - 玩家完成了整场比赛
    • gold - 玩家在比赛结束之后剩余的金钱
    • last_hits - 正补数
    • denies - 反补数
    • gold_per_min - 玩家每秒金钱
    • xp_per_min - 玩家每秒经验
    • gold_spent - 整场比赛玩家花费的金钱
    • hero_damage - 对英雄伤害
    • tower_damage - 对塔伤害
    • hero_healing - 对其他英雄的治疗量
    • level - 最后的等级
    • ability_upgrades - 一个数组详细的记录玩家每次加点记录
      • ability - 所加技能的ID
      • time - 加点时间(/秒)从比赛开始计算
      • level - 加点等级
    • additional_units - 玩家额外控制的单位信息 (其实就是熊德的宝宝)
      • unitname - 单位名字
      • item_0 - 比赛结束时物品栏 左上 物品ID
      • item_1 - 比赛结束时物品栏 中上 物品ID
      • item_2 - 比赛结束时物品栏 右上 物品ID
      • item_3 - 比赛结束时物品栏 左下 物品ID
      • item_4 - 比赛结束时物品栏 中下 物品ID
      • item_5 - 比赛结束时物品栏 右下 物品ID
    • season - ?
    • radiant_win - radiant赢了为true,false反之
    • duration - 整场比赛的用时
    • start_time - date in UTC seconds since Jan 1, 1970 (unix time format)
    • match_id - 比赛数字ID
    • match_seq_num - 比赛序号 - the order in which matches are recorded
    • tower_status_radiant - 11位 unsinged int: 见此链接
    • tower_status_dire - 11位 unsinged int: 见此链接
    • barracks_status_radiant - 6位 unsinged int: 见此链接
    • barracks_status_radiant - 6位 unsinged int: 见此链接 (吐槽,应该是dire不是radiant吧,还有应该是unsigned不是unsinged吧)
    • cluster - 见下方的REPLAYS
    • first_blood_time - 一血诞生的时间
    • replay_salt - 见下方REPLAYS 目前已从API中移除
    • lobby_type - lobby类型 (见上方GetMatchHistory)
    • human_players - 比赛中human players的数量
    • leagueid - 比赛所属leauge的ID (见上方GetMatchHistory)
    • positive_votes - 多少人顶
    • positive_votes - 多少人踩(估计这个写错了,应该是 negative_votes -多少人踩)
    • game_mode - 比赛模式
      • '1' : 'All Pick',
      • '2' : "Captains Mode",
      • '3' : 'Random Draft',
      • '4' : 'Single Draft',
      • '5' : 'All Random',
      • '6' : '?? INTRO/DEATH ??',
      • '7' : 'The Diretide',
      • '8' : "Reverse Captains Mode",
      • '9' : 'Greeviling',
      • '10' : 'Tutorial',
      • '11' : 'Mid Only',
      • '12' : 'Least Played',
      • '13' : 'New Player Pool'
    • 接下来的字段只会在 teams applied to radiant and dire 的时候有(i.e. this is a league match in a private lobby (英文不好,话说radiant和dire分别代表天辉和夜魇么?)
      • radiant_name - radiant 队伍的名字
      • radiant_logo -  radiant 队伍的LOGO (想要获得图片, 见下方FAQ)
      • radiant_team_complete - true为所有radiant的成员都属于本队伍, false反之 (i.e. are the stand-ins {false} or not {true})
      • dire_name - dire队伍的名字
      • dire_logo - the dire 队伍的LOGO (想要获得图片, 见下方FAQ)
      • dire_team_complete - true为所有dire的成员都属于本队伍, false反之  (i.e. are the stand-ins {false} or not {true})

下篇地址:http://www.cnblogs.com/Scohura/p/3600973.html

你应该在开始API开发之前知道的事(上)(翻译)的更多相关文章

  1. 你应该在开始API开发之前知道的事(下)(翻译)

    放了十多天,一直在玩没写,今天终于要把坑填完了.有部分没翻,主要是一般都用不上的,有兴趣的朋友可以自己翻下. 上篇地址 :http://www.cnblogs.com/Scohura/p/357360 ...

  2. 第六代智能英特尔® 酷睿™ 处理器图形 API 开发人员指南

    欢迎查看第六代智能英特尔® 酷睿™ 处理器图形 API 开发人员指南,该处理器可为开发人员和最终用户提供领先的 CPU 和图形性能增强.各种新特性和功能以及显著提高的性能. 本指南旨在帮助软件开发人员 ...

  3. 天气预报API开发

    天气预报API开发 一.        寻觅篇 最近想要跟着视频练习一下利用API开发一个天气预报系统,就在网上找了一下可以用的API,结果好多都已经失效了... 1.       百度车联网天气预报 ...

  4. 高性能PHP框架thinkphp5.0.0 Beta发布-为API开发而设计

    ThinkPHP V5.——为API开发而设计的高性能框架 ThinkPHP5..0版本是一个颠覆和重构版本,采用全新的架构思想,引入了很多的PHP新特性,优化了核心,减少了依赖,实现了真正的惰性加载 ...

  5. ASP.NET Core Web API 开发-RESTful API实现

    ASP.NET Core Web API 开发-RESTful API实现 REST 介绍: 符合REST设计风格的Web API称为RESTful API. 具象状态传输(英文:Representa ...

  6. 基于.Net Framework 4.0 Web API开发(2):ASP.NET Web APIs 参数传递方式详解

    概述:  ASP.NET Web API 的好用使用过的都知道,没有复杂的配置文件,一个简单的ApiController加上需要的Action就能工作.调用API过程中参数的传递是必须的,本节就来谈谈 ...

  7. API 开发实践

    整个2015年,如果要给自己打上一个标签的话,那应该就是 API. 在各个不同的系统中定制各种 API 框架. 在做商城对接各种电商 ERP 的 API 开发中,我采用的是兼容SHOPEX 的 API ...

  8. 报表引擎API开发入门— EJB程序数据源

    我们前面讲了几个数据源,今天我们来讲一下EJB数据源,这篇讲完我们数据源这部分就讲完了.数据连接不需要直接访问数据库,而是使用EJB做为数据源.FR通过定义程序数据集使用EJB的相关类获取到EJB数据 ...

  9. Rest API 开发 学习笔记(转)

    Rest API 开发 学习笔记 概述 REST 从资源的角度来观察整个网络,分布在各处的资源由URI确定,而客户端的应用通过URI来获取资源的表示方式.获得这些表徵致使这些应用程序转变了其状态.随着 ...

随机推荐

  1. [NHibernate]N+1 Select查询问题分析

    目录 写在前面 文档与系列文章 N+1 Select查询问题分析 总结 写在前面 在前面的文章(延迟加载,立即加载)中都提到了N+1 Select的问题,总觉得理解的很不到位,也请大家原谅,这也是为什 ...

  2. 搭建XMPP学习环境

    XMPP(Extensible Messaging and Presence Protocol,前称Jabber)是一种以XML为基础的开放式IM协议.xmpp被人熟知,google talk肯定有一 ...

  3. nyoj 218 Dinner(贪心专题)

    Dinner 时间限制:100 ms  |  内存限制:65535 KB 难度:1   描述 Little A is one member of ACM team. He had just won t ...

  4. [Python] Python中的一些特殊函数

    1. 过滤函数filter 定义:filter 函数的功能相当于过滤器.调用一个布尔函数bool_func来迭代遍历每个列表中的元素:返回一个使bool_func返回值为true的元素的序列. a=[ ...

  5. Sublime编辑器安装使用

    用习惯了VS2010强大的IDE工具,但也被它折腾过.烦恼过,当vs加载超过万行的脚本代码时,界面半天才反应,经常卡死,电脑配置决定算得上顶呱呱. 不喜欢逆来顺受,于是选择了txt文本编辑器,最原始的 ...

  6. CentOS6.3 编译安装LAMP(4):编译安装 PHP5.3.27

    所需源码包: /usr/local/src/PHP-5.3.27/libmcrypt-2.5.8.tar.gz /usr/local/src/PHP-5.3.27/mhash-0.9.9.9.tar. ...

  7. Mac中安装Vim7.4

    Mac上的Vim Mac本身其实是预装了Vim的,但是目前的系统中都是Vim7.3版本的,而最新的Vim已经是7.4版了,因此为了能够使用最新版的vim,必须要对Mac中的vim要么升级,要么重装.在 ...

  8. 两个int的和判断溢出

    long a,b; cin>>a>>b; long i; i = a+b; if((i^a)<0 && (i^b)<0) cout<<& ...

  9. Shell脚本

    shell script,是一种为shell编写的脚本程序. 业界所说的shell通常是指shell脚本.shell和shell script.

  10. 【Network】Calico, Flannel, Weave and Docker Overlay Network 各种网络模型之间的区别

    From the previous posts, I have analysed 4 different Docker multi-host network solutions - Calico, F ...