How can I get in game player ELO with the Riot Games API without reaching the API limit?

限于喜欢 提交于 2020-01-07 05:12:12

问题


I have a question about the RiotGames API. I have an API Token from Riot Games and its limited to 10 Requests per second. However, when I want to read in game info with player Elo + Divisions, I need to do another request. With the in game info I only get champion runes masteries and so on, but I still need the elo, so I need to do another Request to the server.

By the time I have looped all 10 players, I have reached the API limit because I need to do the general request for a player list and then other requests for each player.


回答1:


You could do some error handling to retry the request when you receive a response that says your limit has exceeded.

function request(player)
  response = riotGamesApi(player1)
  if response.status == "limit exceeded"
    response = request(player)
  else
    return response
  end
end

This will call itself recursively until you receive a valid response



来源:https://stackoverflow.com/questions/35260170/how-can-i-get-in-game-player-elo-with-the-riot-games-api-without-reaching-the-ap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!