你应该在开始API开发之前知道的事(下)(翻译)
放了十多天,一直在玩没写,今天终于要把坑填完了。有部分没翻,主要是一般都用不上的,有兴趣的朋友可以自己翻下。
上篇地址 :http://www.cnblogs.com/Scohura/p/3573606.html
紧接上篇的:
GetMatchHistoryBySequenceNum
Used to get the matches in the order which they were recorded (i.e. sorted ascending by match_seq_num).
This means that the first match on the first page of results returned by the call will be the very first public mm-match recorded in the stats.
可用选项
start_at_match_seq_num=<id> # Start the search at the indicated match id, descending
matches_requested=<n> # Maximum is 25 matches (default is 25)
返回字段格式:
见GetMatchHistory.
GetHeroes
用来获取一份 UP-TO-DATE 的英雄列表。
可用选项(字段):
只有公共选项(见上)
例子:
要求何种语言获取英雄列表:
https://api.steampowered.com/IEconDOTA2_570/GetHeroes/v0001/?key=<key>&language=en_us
https://api.steampowered.com/IEconDOTA2_570/GetHeroes/v0001/?key=<key>&language=zh_cn
返回字段格式:
heroes - heroes数组:
- name - 英雄在比赛中的 "code name"
- id - 英雄的 ID
- localized_name - 英雄的 text name (language specific result - 如果没有输入语言要求的话,这个字段不会出现)
- count - 数组中的英雄数量
GetLeagueListing
用来获取你可以在客户端看到的联赛列表 (i.e. you can buy a ticket to them).
结合GetLiveLeagueGames使用.
可用选项
公共选项 (见上方)
例子:
https://api.steampowered.com/IDOTA2Match_570/GetLeagueListing/v0001/?key=<key>&language=zh_cn
返回字段格式:
- leagues - 联赛数组:
- name - 联赛全称 (可选语言)
- leagueid - the league's 数字 ID
- description - 联赛描述(可选语言)
- tournament_url - 官方赛事地址
GetLiveLeagueGames
用来获取当前正在比赛的联赛列表
可用选项
公共选项 (见上方) - 注意,如果没有语言要求, API will return the in-game "string" placeholders for all fields marked with (language specific).
Result Field Format:
- games - an array of the games:
- players - a list of players in the game
- account_id - the 32-bit account ID
- name - the player's display name
- hero_id - the hero ID of the hero that this player is playing as
- team - what team the player is currently playing on:
- 0 = RADIANT
- 1 = DIRE
- 2 = BROADCASTER
- 4 = UNASSIGNED
- radiant_team - information about the radiant's tournament team
- team_name - the team's name
- team_id - the team's ID
- team_logo - the team's logo (for details on fetching this image, see FAQ below)
- complete - true if all players belong to this team, false otherwise (i.e. are the stand-ins {false} or not {true})
- dire_team - information about the dire's tournament team
- same as radiant_team above
- lobby_id - the ID for the match's lobby
- spectators - the number of spectators currently watching
- tower_state - a 22-bit uint detailing if each tower is alive (see this link for exact details)
- league_id - the ID of the league this match is for (see GetLeagueListing above).
- players - a list of players in the game
GetTeamInfoByTeamID
用来获取已经在客户端中创建的战队信息.
注意这个API请求默认返回以ID升序排列的战队列表(100个每页)
可用字段
start_at_team_id # the ID of the team to start at
teams_requested # the number of teams to return (default is 100)
例子
获取指定战队信息
https://api.steampowered.com/IDOTA2Match_570/GetTeamInfoByTeamID/v001/?key=<key>&start_at_team_id=<team's id>&teams_requested=1
返回字段格式:
teams - an array of the teams
- team_id - 战队数字ID
- name - 战队名
- tag - 战队缩写
- time_created - 战队建立的Unix time
- rating - ????????????????? something to do with MM ranking?
- logo - 战队logo (获取图片信息, 见下方FAQ)
- logo_sponsor - 战队赞助商(们)的图片 (获取图片信息, 见下方FAQ)
- country_code - 战队来自国家 (see http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes) (empty string if not specified)
- url - 战队主页 (empty string if not specified)
- games_played_with_current_roster - 战队匹配比赛局数
- player_X_account_id - (where X >= 0) there is one field per player in the roster
- admin_account_id - 在DOTA客户端中,队长的账号ID
- league_id_X (源地址无此字段说明,猜测是参加的联赛ID)
GetPlayerSummaries
用来获取玩家的Steam账户
更全面的介绍, 见 http://wiki.teamfortress.com/wiki/We...layerSummaries
EconomySchema
Used to get list of economy (cosmetic) items.
For full details, see http://wiki.teamfortress.com/wiki/WebAPI/GetSchema
ITEMS
非常不幸,目前没有提供item list的API请求.
IDs
物品 IDs 可以在下面的游戏文件中找到:
<path to steam>/Steam/steamapps/common/dota 2 beta/game/dota/scripts/npc/items.txt
Images
这里有两个方法, 一种从游戏文件中直接获得full quality images:
见 CyborgMatt's guide here 如何打开 vpk 文件.
the images can be found in the file:
<path to steam>/Steam/steamapps/common/dota 2 beta/dota/pak01_dir.vpk
Then inside this file, they can be found in
root\resource\flash3\images\
另一种方法: get high-quality images from the steam servers:
http://cdn.dota2.com/apps/dota2/images/items/<name>_lg.png
<name> 是在上方TXT文件中的 "name" , 没有 "item_" 作为开头。
HEROES
IDs
使用上方 GetHeroes API 获得英雄的IDs列表
Images
使用上方ITEMS提的方法
或者你可以从 valve's 服务器获得:
这里有4种不同的图像, 都按照这个格式获取:
http://cdn.dota2.com/apps/dota2/images/heroes/<name>_<suffix>
<name> 是GetHeros得到的英雄的"name", 没有 "npc_hero_dota_" 作为开头 ; <suffix> 是下面中任意一种:
1) tiny horizontal portrait - 35x20px (已经不可用)
<suffix> = eb.png
2) small horizontal portrait - 59x33px
<suffix> = sb.png
3) large horizontal portrait - 205x11px
<suffix> = lg.png
4) full quality horizontal portrait - 256x114px
<suffix> = full.png
5) full quality vertical portrait - 234x272px (注意这是 .jpg)
<suffix> = vert.jpg
REPLAYS
我如何获得比赛replay的地址?
Replays 由接下来的URL组成:
http://replay<cluster>.valve.net/570/<match_id>_<replay_salt>.dem.bz2
<cluster>, <match_id> 和 <replay_salt> 可以在 GetMatchDetails获得。
见 https://developer.valvesoftware.com/..._2_Demo_Format 了解具体如何解析下载下来的Repaly文件
STEAMIDS
Dota2 API 通常给你玩家的32位 SteamIDs .
为了根据32位SteamID获得Steam Names, 你需要先在32位 ID和64位 ID间转化:
- On a system that supports up to 64-bit numbers you can do the following:
- STEAMID64 - 76561197960265728 = STEAMID32
- STEAMID32 + 76561197960265728 = STEAMID64
- OR
- STEAMID32 = The right-most 32-bits of STEAMID64
- STEAMID64 = concatenate("00000001000100000000000000000001", STEAMID32);
- On a system that only supports up to 32-bit numbers - it's trickier. You have to rely on the language's built-in "big number" functions (i.e. PHP's gmp extension: see this post for details)
一旦你有了 64-bit ID, 你将可以用 GetPlayerSummaries 获取他们的信息!
如何获得一些人64-bit ID来搜索:
如果你有他们的vanity地址, 会是这样的:
http://steamcommunity.com/id/<vanity_name>/
使用 ResolveVanityURL (see http://wiki.teamfortress.com/wiki/We...solveVanityURL for more info), 你可以获得64位ID:
http://api.steampowered.com/ISteamUser/ResolveVanityURL/v0001/?key=<key>&vanityurl=<vanity_name>
如果你有他们的ID地址:
http://steamcommunity.com/profiles/<id>/
这<id> 就是他们的64位ID!
如果你只有Steam-Name:
你可以用来直接搜索DOTA2 API GetMatchHistory
你可以发现他们的32位ID然后按照上面的方法转化为64位ID.
FAQ
match history 和 details 是否可以获得非公开匹配的信息?
目前不可以. 我们正在寻找一个可能的OATUH认证系统,在能够保证玩家账号安全的情况下获取他们的匹配记录,并提供给第三方网站获取。我们希望有更多的相关信息尽快公布。
是否有正在进行的比赛的WebAPI?
还没有! 我们已经建议了, 还在等待回应!
关于API调用次数是否有限制呢?
- You must manually limit your requests to one request per second in order to reduce the strain on the servers
- If you get a 503 Error: 如果匹配服务器正忙或者你频繁调用超出限制,你将可能获得503错误。请等待30秒然后重试。.
- 请注意 WebAPI T&C's 的说明, 你被限制每天100,000 次API 请求.
我可以保存数据在数据库中或者其他类似的么?
可以! 事实上, 我们建议这样减少服务器的压力.
什么是 "Unix time"/"UTC seconds since..."?
http://en.wikipedia.org/wiki/Unix_time
How do I get a player's 32- or 64-bit SteamID?
见上方 SteamIDs !
How to I fetch a team's logo?
见DanielJ举的例子 here: http://dev.dota2.com/showthread.php?...l=1#post462059
虽然没有给出 image extension, 这是 PNG.
I want to start developing, should I jump right into grabbing data using the API?
Short answer; no. You should not.
如果你同时开发你的应用, 重复的执行API请求,去获取你刚刚扔掉的数据,这是相当愚蠢和轻率的.
另外, 有两种选择:
1) (推荐) 手动的执行一些API请求后将结果存到你的硬盘上, 然后使用这些测试直到你自信你的应用能够完成你需要的处理.
2) 如果你正在开发实际动态的API调用, (首先你要确认你已经根据上面实现一个适当的请求限制)如果要使用 Dota2 Beta TEST API, 和Dota2 Beta API只有地址不相同:
Replace "IDOTA2Match_570" with "IDOTA2Match_205790"
请回复任何我需要添加的WRONG/THINGS.
多谢
CHANGE LOG:
- 11/10/2012 - Created Thread.
- 12/10/2012 - Made SteamIDs its own section, changed to using ResolveVanityURL (thanks to RJackson).
- 15/10/2012 - Quoted Zoid's "API is down" post.
- 27/01/2013 - Removed api is down post, added link to the api's T&C's, fixed up a few errors (thanks to sema), added to-do list.
- 31/01/2013 - Added info about leaver_status (thanks to adrianlegg) and lobby_type (thanks to Cyborgmatt).
- 03/02/2013 - Updated GetMatchHistory & GetMatchDetails (thanks to adrianlegg for game_mode data).
- 06/02/2013 - Updated GetMatchHistory & GetMatchDetails with latest parameters from ISteamWebAPIUtil/GetSupportedAPIList. Added GetLeagueListing, GetLiveLeagueGames & GetMatchHistoryBySequenceNum. Added info about team logo picture files in FAQ.
- 07/02/2013 - Added GetTeamInfoByTeamID.
- 03/04/2013 - Changed the links which show how tower_status and barracks_status work.
- 19/02/2014 - Updated the hero and item image urls for valve's servers.
TODO:
- New functionality as per http://www.joindota.com/en/news/6545...er-file-layout
- items in VPK as per http://dev.dota2.com/showthread.php?...ight=items.txt (thanks to alcaras)
- fantasy API
你应该在开始API开发之前知道的事(下)(翻译)的更多相关文章
- 你应该在开始API开发之前知道的事(上)(翻译)
这篇文章的源地址:http://dev.dota2.com/showthread.php?t=58317 由于文章内容较多,英语水平有限,准备尝试着以中英混搭的形式翻译,免得曲解一些不懂内容的意思.以 ...
- 第六代智能英特尔® 酷睿™ 处理器图形 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来获取资源的表示方式.获得这些表徵致使这些应用程序转变了其状态.随着 ...
随机推荐
- mate标签
<meta charset='utf-8'> <!-- 优先使用 IE 最新版本和 Chrome --> <meta http-equiv="X-UA-C ...
- Python之路【第十九篇】自定义分页实现(模块化)
自定义分页 1.目的&环境准备 目的把分页写成一个模块的方式然后在需要分页的地方直接调用模块就行了. 环境准备Django中生成一个APP并且注册,配置URL&Views 配置URL ...
- Excel—身份证生日提取
一.只有18位的身份证号码 如: 身份证号 330682199302264000 41120019890823729X 231081199002256839 131101198203154666 36 ...
- codevs3163 抄书问题2
题目描述 Description 现在要把M本有顺序的书分给K个人复制(抄写),每一个人的抄写速度都一样,一本书不允许给两个(或以上)的人抄写,分给每一个人的书,必须是连续的,比 如不能把第一.第三. ...
- Rails的三种环境----开发环境,生产环境和测试环境
Rails 的三个环境 Rails 的应用程序预设提供了三种不同的执行模式: development environment 开发模式,用在你的开发的时候 test environment 测试模式, ...
- PHP模板引擎正则替换函数 preg_replace 与 preg_replace_callback 使用总结
在编写PHP模板引擎工具类时,以前常用的一个正则替换函数为 preg_replace(),加上正则修饰符 /e,就能够执行强大的回调函数,实现模板引擎编译(其实就是字符串替换). 详情介绍参考博文:P ...
- Java 23种设计模式 (通俗易懂解释收集整理)
(补充中...) P02 抽象工程模式 P14 TemplateMethod 模板方法模式 讲清楚了为什么叫做模板方法 http://www.cnblogs.com/java-my-life/arc ...
- maven项目打包成可执行的jar
编写功能类: package com.hpay.FileToZkUtil; import java.io.File; import java.io.FileInputStream; import ja ...
- 使用http.sys,让delphi 的多层服务飞起来
核心提示:一直以来,delphi 的网络通讯层都是以indy 为主,虽然indy 的功能非常多,涉及到网络服务的各个方面,但是对于大多数多层服务来说,就是需要一个快速.稳定.高效的传输层.Delphi ...
- 8.7 jquery-dom manipulation
// 获得设定内容 [text(),html(),val()]; // 获得设定属性 [attr(),removeAttr()]; // 获得设定 css class [addClass,remove ...