TypeScript-first Riot Games API wrapper for Node.js, with built-in Data Dragon support.
RiftJS wraps common Riot API and Data Dragon use cases in a small API:
- Resolve account details from Riot ID
- Get summoner details from PUUID
- Get rank entries and queue-split rank summaries
- Get match IDs, match details, and match timelines
- Fetch all match IDs with paging and optional pacing
- Fetch Data Dragon champion and item static data
The package is authored in TypeScript and published as compiled CommonJS with .d.ts types.
npm install @timmsy/riftjsYou need a Riot developer key:
Create a .env file in your app:
RIOT_API_KEY=RGAPI-your-key-here
REGION=EUW1Notes:
RIOT_API_KEYis required forRiotAPI.REGIONis optional. Default isEUW1.
const { RiotAPI, DataDragon } = require('@timmsy/riftjs');
async function main() {
const riot = new RiotAPI();
const account = await riot.getAccountByRiotId('PlayerName#EUW');
const summoner = await riot.getSummonerByPuuid(account.puuid);
const matchIds = await riot.getMatchlistByPuuid(account.puuid, { start: 0, count: 5 });
console.log('Summoner level:', summoner.summonerLevel);
console.log('Recent matches:', matchIds);
const dd = new DataDragon();
const champions = await dd.getChampions();
console.log('Champion count:', Object.keys(champions.data || {}).length);
}
main().catch((err) => {
console.error(err.message);
process.exitCode = 1;
});import { RiotAPI, DataDragon } from '@timmsy/riftjs';
async function main(): Promise<void> {
const riot = new RiotAPI();
const account = await riot.getAccountByRiotId('PlayerName#EUW');
const rank = await riot.getRankByPuuid(String(account.puuid || ''));
console.log('Solo queue:', rank.solo);
console.log('Flex queue:', rank.flex);
const dd = new DataDragon();
const items = await dd.getItems();
console.log('Item count:', Object.keys((items.data as Record<string, unknown>) || {}).length);
}
main().catch((err: unknown) => {
const message = err instanceof Error ? err.message : 'Unknown error';
console.error(message);
process.exitCode = 1;
});new RiotAPI() reads:
RIOT_API_KEYfrom environmentREGIONfrom environment (defaultEUW1)
- Input:
riotId: string("Name#Tag"format, or name-only withtagLine)tagLine?: string | nullregion?: RegionCode
- Output: account payload (includes
puuid) - Example:
const account = await riot.getAccountByRiotId('Timmsy#BRUV');- Input:
puuid: stringregion?: RegionCode
- Output: Summoner V4 payload
- Input:
puuid: stringregion?: RegionCode
- Output: League V4 rank entries array
- Input:
puuid: stringregion?: RegionCode
- Output:
solo: solo queue entry with computedwinRate(ornull)flex: flex queue entry with computedwinRate(ornull)entries: original rank entries
Queue constants used internally:
RANKED_SOLO_5x5RANKED_FLEX_SR
- Input:
puuid: stringoptions?: MatchlistOptionsregion?: RegionCode
- Output:
string[]of match IDs
MatchlistOptions:
startTime?: number(epoch seconds)endTime?: number(epoch seconds)queue?: numbertype?: stringstart?: numbercount?: number(Riot max is 100 for this endpoint)
- Input:
matchId: string(exampleEUW1_1234567890)region?: RegionCode
- Output: Match V5 payload (
metadata+info)
- Input:
matchId: stringregion?: RegionCode
- Output: Match timeline payload
- Purpose: fetches all match IDs in pages of up to 100.
- Input:
puuid: stringoptions?: MatchlistOptions(filters + optional start offset)region?: RegionCodepacing?: { delayMs?: number; maxMatches?: number | null }
- Output:
string[]of aggregated match IDs
- Purpose: fetches match IDs, then fetches each match payload.
- Input:
puuid: stringoptions?: MatchlistOptionsregion?: RegionCodepacing?: { pageDelayMs?: number; detailDelayMs?: number; maxMatches?: number | null }
- Output:
matchIds: string[]matches: object[]
version?: string | null- Omit to auto-resolve the latest Data Dragon version
- Pass a version like
15.4.1to pin
locale?: string- Defaults to
en_US
- Defaults to
- Output: Data Dragon champion payload (
champion.json)
- Output: Data Dragon item payload (
item.json)
Supported REGION / region values:
BR1, EUN1, EUW1, JP1, KR, LA1, LA2, NA1, OC1, TR1, RU, PH2, SG2, TH2, TW2, VN2
Routing behavior:
- Platform APIs (example Summoner V4) use platform hosts like
euw1.api.riotgames.com. - Regional APIs (example Match V5 / Account V1) use shard hosts like
europe.api.riotgames.com.
RiftJS normalizes errors to plain Error objects with readable messages:
- HTTP response errors:
API error <status>: <message> - No response from Riot:
No response received from the server - Request setup/other errors:
Request error: <message> - Data Dragon wrapper errors:
DataDragon error: <message>
git clone https://github.com/timmsy1998/RiftJS.git
cd RiftJS
npm install
npm run buildnpm testTest script behavior:
- Riot endpoint checks run only when
RIOT_API_KEYandTEST_RIOT_IDare set. - Data Dragon checks always run.
Optional .env values for tests:
TEST_RIOT_ID=YourRiotName
TEST_TAG_LINE=EUWMaintainer notes:
- See
MAINTAINER_NOTES.mdfor project conventions and release checklist.
Published entry points:
main:dist/index.jstypes:dist/index.d.ts
Build command:
npm run buildCompiled output is written to dist/.
MIT License © 2025 James Timms. See LICENSE.
- npm: https://www.npmjs.com/package/@timmsy/riftjs
- GitHub: https://github.com/timmsy1998/RiftJS
- Riot Developer Portal: https://developer.riotgames.com/
