Skip to content

Instantly share code, notes, and snippets.

@danker
Created August 2, 2015 03:59
Show Gist options
  • Save danker/de3c976731ccb09af835 to your computer and use it in GitHub Desktop.
Save danker/de3c976731ccb09af835 to your computer and use it in GitHub Desktop.
Groovy script that will pull stats on recent games for the specified SummonerID.
import groovyx.net.http.RESTClient
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1' )
def API_KEY = "INSERT-API-KEY-HERE"
def SUMMONER_ID = "28450305"
// FULL DOCUMENTATION AT: https://developer.riotgames.com/api/methods
def client = new RESTClient('https://na.api.pvp.net')
def RECENT_GAMES_PATH = "/api/lol/na/v1.3/game/by-summoner/" + SUMMONER_ID + "/recent"
def response = client.get(path:RECENT_GAMES_PATH, query:[api_key:API_KEY])
def games = response.responseData.games
games.each { game ->
println("${new Date(game.createDate)}: ${game.gameType}/${game.subType} >> ${game.stats.win ? 'WIN':'LOSS'} - "
+ "${game.stats.championsKilled ? game.stats.championsKilled:0}/"
+ "${game.stats.numDeaths ? game.stats.numDeaths:0}/"
+ "${game.stats.assists ? game.stats.assists:0}")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment