你应该在开始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来获取资源的表示方式.获得这些表徵致使这些应用程序转变了其状态.随着 ...
随机推荐
- [Head First设计模式]餐馆中的设计模式——命令模式
系列文章 [Head First设计模式]山西面馆中的设计模式——装饰者模式 [Head First设计模式]山西面馆中的设计模式——观察者模式 [Head First设计模式]山西面馆中的设计模式— ...
- java运行过程
一.安装环境 大家在开发Java的时候,首先回装一个java的开发环境,一个JDK(也包含了JRE),然后设置环境变量,这个过程我就不细说了,大家装完后有没有发现,在装完这个环境的同时在安装JRE,在 ...
- Bash 4.4 中新增的 ${parameter@operator} 语法
Bash 4.4 中新增了一种 ${...} 语法,长这样:${parameter@operator}.根据不同的 operator,它展开后的值可能是 parameter 这个参数的值经过某种转换后 ...
- 大熊君JavaScript插件化开发------(实战篇之DXJ UI ------ ProcessBar)
一,开篇分析 Hi,大家好!大熊君又和大家见面了,还记得前两篇文章吗.主要讲述了以“jQuery的方式如何开发插件”,以及过程化设计与面向对象思想设计相结合的方式是 如何设计一个插件的,两种方式各有利 ...
- 【JWT】JWT+HA256加密 Token验证
目录 Token验证 传统的Token验证 JWT+HA256验证 回到顶部 Token验证 最近了解下基于 Token 的身份验证,跟大伙分享下.很多大型网站也都在用,比如 Facebook,Twi ...
- tyvj1148 小船弯弯
描述 童年的我们,充满了新奇的想法.这天,小朋友们用彩虹画笔在云霞上绘制了世界上最美丽的图画.那描绘的是一条大河波浪宽,风吹稻花香两岸的情景.欣赏着自己的作品,小朋友们别提多开心了.这时,Q小朋友对C ...
- PHP格式化显示文件大小函数
用filesize() 函数可以返回文件的大小,可是返回值是以字节(B)为单位的,看起来不方便.怎么让它根据文件的大小自动以KB.MB.GB为单位显示呢,用下面这个函数就可以实现了. <?php ...
- MVC项目使用easyui的filebox控件上传文件
开发环境:WIN10+IE11,浏览器请使用IE10或以上版本 开发技术框架MVC4+JQuery Easyui+knockoutjs 效果为弹出小窗体,如下图 1.前端cshtml文件代码(只包含文 ...
- 06OC之内存管理
在高级语言中,例如C#是通过垃圾回收机制(GC)来解决这个问题,但是在OC并没有类似的垃圾回收机制,因此必须由程序员手动去维护.今天就讲讲OC中的内存管理: 一.内存管理原理 在Xcode4.2之后的 ...
- php中几个字符串替换函数详解
在php中字符替换函数有几个如有:str_replace.substr_replace.preg_replace.preg_split.str_split等函数,下面我来给大家总结介绍介绍. 一.st ...