Skip to content

RiftJS: A lightweight Node.js wrapper for the Riot Games API, providing easy access to League of Legends game data.

License

Notifications You must be signed in to change notification settings

Timmsy1998/RiftJS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RiftJS

A lightweight Node.js wrapper for the Riot Games API, providing easy access to League of Legends game data.

npm version GitHub license

Overview

RiftJS simplifies interaction with the Riot Games API and DataDragon static data. It supports fetching account details, summoner info, match history, and game data using a modular endpoint structure. Built with axios and dotenv, it’s designed for developers building League of Legends tools or applications.

Features

  • RiotAPI: Fetch account data by Riot ID, summoner data by PUUID, match history, and match details.
  • DataDragon: Access static game data like champions and items.
  • Region Support: Handles platform (e.g., EUW1) and shard (e.g., europe) routing.
  • Modular Design: Endpoints are organized in an /endpoints/ directory for easy extension.

Installation

Install RiftJS via npm:

npm install @timmsy/riftjs

You’ll also need a Riot Games API key from developer.riotgames.com.

Setup

  1. Install Dependencies: Ensure you have Node.js installed, then run the install command above.

  2. Configure Environment: Create a .env file in your project root with your API key and region:

    RIOT_API_KEY=RGAPI-your-api-key-here
    REGION=EUW1
    
    • Replace RGAPI-your-api-key-here with your API key.
    • Use a short region code (e.g., EUW1, NA1). See Region Mapping for details.

Usage

Here’s a basic example to get started:

const { RiotAPI, DataDragon } = require('@timmsy/riftjs');

// Initialize RiotAPI
const riot = new RiotAPI();

// Fetch account, summoner, and match data
async function fetchPlayerData() {
  try {
    const account = await riot.getAccountByRiotId('Timmsy#BRUV');
    console.log('Account:', account);

    const summoner = await riot.getSummonerByPuuid(account.puuid);
    console.log('Summoner:', summoner);

    const matchlist = await riot.getMatchlistByPuuid(account.puuid, { start: 0, count: 5 });
    console.log('Matchlist:', matchlist);

    const match = await riot.getMatchById(matchlist[0]);
    console.log('Match:', match);
  } catch (error) {
    console.error('Error:', error.message);
  }
}

// Initialize DataDragon
const dd = new DataDragon();

async function fetchStaticData() {
  try {
    const champions = await dd.getChampions();
    console.log('Champions:', champions.data);

    const items = await dd.getItems();
    console.log('Items:', items.data);
  } catch (error) {
    console.error('Error:', error.message);
  }
}

// Run the examples
fetchPlayerData();
fetchStaticData();

API Reference

RiotAPI

  • getAccountByRiotId(riotId, [tagLine], [region]): Fetch account by Riot ID (e.g., Timmsy#BRUV).
  • getSummonerByPuuid(puuid, [region]): Get summoner data by PUUID.
  • getMatchlistByPuuid(puuid, [options], [region]): Get match history (options: { start, count }).
  • getMatchById(matchId, [region]): Get match details.

DataDragon

  • getChampions(): Fetch all champion data.
  • getItems(): Fetch all item data.

Region Mapping

RiftJS uses a region map to route requests correctly:

  • Platform Routing (e.g., Summoner V4):
    • EUW1euw1.api.riotgames.com
    • NA1na1.api.riotgames.com
  • Shard Routing (e.g., Account V1, Match V5):
    • EUW1europe.api.riotgames.com
    • NA1americas.api.riotgames.com

Supported regions: BR1, EUN1, EUW1, JP1, KR, LA1, LA2, NA1, OC1, TR1, RU, PH2, SG2, TH2, TW2, VN2.

Keywords

  • riot-api
  • league-of-legends
  • lol-api
  • datadragon
  • summoner
  • match-history
  • game-data
  • node-js
  • javascript
  • api-wrapper

Development

To contribute or run locally:

  1. Clone the repo:
    git clone https://github.com/timmsy1998/RiftJS.git
    cd RiftJS
    
  2. Install dependencies:
    npm install
    
  3. Create a .env file (see Setup).
  4. Test with node test.js (requires a valid API key).

License

MIT License © 2025 James Timms. See LICENSE for details.

Links

About

RiftJS: A lightweight Node.js wrapper for the Riot Games API, providing easy access to League of Legends game data.

Topics

Resources

License

Stars

Watchers

Forks