你应该在开始API开发之前知道的事(上)(翻译)
这篇文章的源地址:http://dev.dota2.com/showthread.php?t=58317
由于文章内容较多,英语水平有限,准备尝试着以中英混搭的形式翻译,免得曲解一些不懂内容的意思。以下开始为翻译内容:
这篇文章会持续更新, 请在suggesting missing items前查看底部的TODO List
Web开发者现在可以以JSON或者XML格式,获得匹配历史记录及详情并使用在他们自己的应用中。
获得密钥
首先登录 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/
- 如果想要了解所有可用的API,请看 http://wiki.teamfortress.com/wiki/WebAPI
 
常用选项:
注意,除非另有说明,否则默认为空或忽略
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开发之前知道的事(上)(翻译)的更多相关文章
- 你应该在开始API开发之前知道的事(下)(翻译)
		
放了十多天,一直在玩没写,今天终于要把坑填完了.有部分没翻,主要是一般都用不上的,有兴趣的朋友可以自己翻下. 上篇地址 :http://www.cnblogs.com/Scohura/p/357360 ...
 - 第六代智能英特尔® 酷睿™ 处理器图形 API 开发人员指南
		
欢迎查看第六代智能英特尔® 酷睿™ 处理器图形 API 开发人员指南,该处理器可为开发人员和最终用户提供领先的 CPU 和图形性能增强.各种新特性和功能以及显著提高的性能. 本指南旨在帮助软件开发人员 ...
 - 天气预报API开发
		
天气预报API开发 一. 寻觅篇 最近想要跟着视频练习一下利用API开发一个天气预报系统,就在网上找了一下可以用的API,结果好多都已经失效了... 1. 百度车联网天气预报 ...
 - 高性能PHP框架thinkphp5.0.0 Beta发布-为API开发而设计
		
ThinkPHP V5.——为API开发而设计的高性能框架 ThinkPHP5..0版本是一个颠覆和重构版本,采用全新的架构思想,引入了很多的PHP新特性,优化了核心,减少了依赖,实现了真正的惰性加载 ...
 - ASP.NET Core Web API 开发-RESTful API实现
		
ASP.NET Core Web API 开发-RESTful API实现 REST 介绍: 符合REST设计风格的Web API称为RESTful API. 具象状态传输(英文:Representa ...
 - 基于.Net Framework 4.0 Web API开发(2):ASP.NET Web APIs 参数传递方式详解
		
概述: ASP.NET Web API 的好用使用过的都知道,没有复杂的配置文件,一个简单的ApiController加上需要的Action就能工作.调用API过程中参数的传递是必须的,本节就来谈谈 ...
 - API 开发实践
		
整个2015年,如果要给自己打上一个标签的话,那应该就是 API. 在各个不同的系统中定制各种 API 框架. 在做商城对接各种电商 ERP 的 API 开发中,我采用的是兼容SHOPEX 的 API ...
 - 报表引擎API开发入门— EJB程序数据源
		
我们前面讲了几个数据源,今天我们来讲一下EJB数据源,这篇讲完我们数据源这部分就讲完了.数据连接不需要直接访问数据库,而是使用EJB做为数据源.FR通过定义程序数据集使用EJB的相关类获取到EJB数据 ...
 - Rest API 开发 学习笔记(转)
		
Rest API 开发 学习笔记 概述 REST 从资源的角度来观察整个网络,分布在各处的资源由URI确定,而客户端的应用通过URI来获取资源的表示方式.获得这些表徵致使这些应用程序转变了其状态.随着 ...
 
随机推荐
- redis3.2 最新版本启动配置文件redis.conf详细说明
			
Redis.conf文件内容详细说明: # 默认redis不是以后台进程的方式启动,如果需要在后台运行,需要将这个值设置成yes # 以后台方式启动的时候,redis会写入默认的进程文件/var/ru ...
 - linux shell脚本查找重复行/查找非重复行/去除重复行/重复行统计
			
转自:http://blog.sina.com.cn/s/blog_6797a6700101pdm7.html 去除重复行 sort file |uniq 查找非重复行 sort file |uniq ...
 - 什么时候用@Resource,什么时候用@service
			
Spring中什么时候用@Resource,什么时候用@service当你需要定义某个类为一个bean,则在这个类的类名前一行使用@Service("XXX"),就相当于讲这个类定 ...
 - jQuery入门(3)事件与事件对象
			
jQuery入门(1)jQuery中万能的选择器 jQuery入门(2)使用jQuery操作元素的属性与样式 jQuery入门(3)事件与事件对象 jQuery入门(4)jQuery中的Ajax()应 ...
 - 【Alpha版本】冲刺阶段——Day 10
			
我说的都队 031402304 陈燊 031402342 许玲玲 031402337 胡心颖 03140241 王婷婷 031402203 陈齐民 031402209 黄伟炜 031402233 郑扬 ...
 - sublime 编译运行C程序
			
{ "cmd": ["gcc", "${file}", "-o","${file_path}/${file_b ...
 - POJ2914 (未解决)无向图最小割|Stoer-Wagner算法|模板
			
还不是很懂,贴两篇学习的博客: http://www.hankcs.com/program/algorithm/poj-2914-minimum-cut.html http://blog.sina.c ...
 - 实现统一用户体验的BaseActivity
			
对一个规模较大的App开发团队来说,保持统一的代码规范是个好的事情,同时,保持统一的用户体验规范也是个好的事情. 当用户进入一个页面时,一般会有以下交互场景:场景1, 初始化loading,页面从se ...
 - 用 nssm 把 Nginx 安装成 Windows 服务方法
			
总之:用 nssm 比 srvany.exe 简便多了.1. 下载nginx windows版本:http://nginx.org/ 2. 下载 nssm :http://nssm.cc/3. 安装N ...
 - mysql ERROR 1045 (28000): 错误解决办法
			
ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO) ERROR 1045 (28000 ...