Loading...
Loading...
Build League of Legends apps using league-sdk TypeScript library. Use when working with Riot API, summoner/player lookups, match history, champion mastery, ranked stats, live game spectator, or building LoL Discord bots, websites, or apps.
npx skill4agent add adrianmg/league-sdk league-sdkkreuw1420440450400430new Date(match.gameCreation)import { LolClient, NotFoundError, RateLimitError } from 'league-sdk';
const client = new LolClient({
apiKey: process.env.RIOT_API_KEY!,
platform: 'na1'
});
// Player lookup
const player = await client.players.getByRiotId('Name', 'Tag');
// Ranked stats
const soloQ = await player.getSoloQueueStats();
// soloQ.tier, soloQ.division, soloQ.winRate (0-1 decimal)
// Match history
const matches = await player.getMatches({ count: 10, queue: 420 }); // 420 = ranked
for (const match of matches) {
const p = match.getParticipant(player.puuid)!;
console.log(`${p.championName} ${p.kills}/${p.deaths}/${p.assists} - ${p.win ? 'W' : 'L'}`);
}
// Participant stats
const p = match.getParticipant(player.puuid)!;
p.kills; p.deaths; p.assists; p.kda;
p.championName; p.win;
p.items; // { item0-5, trinket }
p.totalCs; p.csPerMinute;
p.damage.toChampions; p.damage.taken;
p.goldEarned; p.visionScore;
// Match stats
match.gameDurationFormatted; // "32:15"
match.queueName; // "Ranked Solo/Duo"
match.blueTeam; match.redTeam;
match.getWinner(); match.didPlayerWin(player.puuid);
// Team comparison
const { blueTeam, redTeam } = match;
console.log(`Blue: ${blueTeam.totalKills}K, ${blueTeam.totalGold}g`);
// Live game (null if not in game)
const game = await player.getLiveGame();
// Mastery
const top = await player.getTopMastery(3);
// m.championName, m.championPoints, m.championLevel
// Static data (no API key needed)
const champs = await client.dataDragon.getChampions();
const items = await client.dataDragon.getItems();
await client.dataDragon.getChampionIconUrl('Ahri');
await client.dataDragon.getItemIconUrl(3157);npx league-sdk-assets --output ./assets --allimport { downloadAllAssets } from 'league-sdk/scripts'na1euw1eun1krjp1br1la1la2oc1tr1rusg2ph2th2tw2vn2retryAfter