你应该在开始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来获取资源的表示方式.获得这些表徵致使这些应用程序转变了其状态.随着 ...
随机推荐
- MyBatis学习总结(一)——MyBatis快速入门
一.Mybatis介绍 MyBatis是一个支持普通SQL查询,存储过程和高级映射的优秀持久层框架.MyBatis消除了几乎所有的JDBC代码和参数的手工设置以及对结果集的检索封装.MyBatis可以 ...
- centos 下测试网速
wget https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py chmod a+rx speedtest. ...
- Spring系列之依赖注入的方式
一.依赖注入方式 对于spring配置一个bean时,如果需要给该bean提供一些初始化参数,则需要通过依赖注入方式,所谓的依赖注入就是通过spring将bean所需要的一些参数传递到bean实例对象 ...
- Pandas-数据选取
Pandas包对数据的常用数据切片功能 目录 [] where 布尔查找 isin query loc iloc ix map与lambda contains DataFrame的索引选取 [] 只能 ...
- [Hadoop] 在Ubuntu系统上一步步搭建Hadoop(单机模式)
1 Hadoop的三种创建模式 单机模式操作是Hadoop的默认操作模式,当首次解压Hadoop的源码包时,Hadoop无法了解硬件安装环境,会保守地选择最小配置,即单机模式.该模式主要用于开发调试M ...
- 前端学习笔记 - Css初级篇
有话先说:我是一只菜鸟,一只都是,从前是现在也是. CSS中的会计元素与行内元素 块级元素特性:占据一整行,总是重起一行并且后面的元素也必须另起一行显示.内联元素特性:和其他内联元素显示在同一行. 可 ...
- UI第十一节——UIActivityIndicatorView
- (void)viewDidLoad { [super viewDidLoad]; // 创建一个UIActivityIndicatorView,大小是固定的 UIActi ...
- iPad版微信终于来临了 微信5.4版搜索更智能 转账就是发消息
等待甚久的iPad版微信终于来临了!昨日微信iOS版本更新至5.4.0.16,新增功能包括搜索公众号.识别图中二维码.面对面收钱,同时适配iPad.(微信5.4安卓版重回ios风格 导航菜单都放底栏位 ...
- python3简单爬虫
最近在抽空学了一下python,于量就拿爬是练了下手,不得不说python的上手非常简单.在网上找了一下,大都是python2的帖子,于是随手写了个python3的.代码非常简单就不解释了,直接贴代码 ...
- cf593d
题意:给出一个有n(n<=200000)的树形图,每条边有一个权值.有两种操作,1是将一个边的权值变小, 2是给定两点a,b和一个值y,用y(long long范围内)依次除以两点之间的路径上的 ...