zoukankan      html  css  js  c++  java
  • 你应该在开始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).

    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:

  • 相关阅读:
    java中变量、对象的存储
    悬停小组件-反馈和返回顶部
    setTimeout、setInternal传递带参数的函数
    jquery绑定事件时如何传递参数
    jQuery判断复选框checkbox是否选中
    bootstrap模态框垂直居中显示
    【转】Spring事务的隔离级别
    第一天 纪念下下
    羊车门
    关于Python课程的一些思考。
  • 原文地址:https://www.cnblogs.com/Scohura/p/3600973.html
Copyright © 2011-2022 走看看