Search code examples
javajsonapiloopsriot-games-api

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


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.


Solution

  • 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