npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lor-api-wrapper

v1.0.0

Published

Node.js Riot Legends of Runeterra API Wrapper

Downloads

7

Readme

lor-api-wrapper

Node.js Riot Legends of Runeterra API Wrapper

Features

  • HTTPS REST API
  • Easy access to API responses
  • Supports all LoR API endpoints
  • No additional dependences required

Installation

Install lifx-api-wrapper with npm:

  npm install lor-api-wrapper

To run this project, you will need a RIOT API key. Get your key here: https://developer.riotgames.com/

Usage

Getting started

import Lor from "lor-api-wrapper.js";

//create instance with our Riot API Token
var lor = new Lor(lorKey);

//Now lor will always use your key

Specify what region to pull from

There are three regions available to pull data from:

  • Americas
  • Europe
  • SEA

Specify the region you want to pull from when calling your request.

//GET USER PUUID BY NAME AND TAG
var puuid = await lor.getUserByName('Otzo', 'Otzo', 'Americas')

API Reference

The wrapper is designed to use selectors that match RIOT API documentation to simply use.

For more information visit api.riotgames.com.

lor.getUserByPuuid(puuid, region)

| Parameter | Type | Example | Description | | :-------- | :------- |:------- |:------------------------ | | puuid | string | 'K-1NczBPzqHG1Ab...' | Required | | region | string | 'Americas' | Required |

lor.getUserByName(userName, tagLine, region)

| Parameter | Type | Example | Description | | :-------- | :------- |:------- |:------------------------ | | userName | string | 'Otzo' | Required | | tagLine | string | 'NA' | Required | | region | string | 'Americas' | Required |

Note: This returns the same information as lor.getUserByPuuid(). The main difference is how you reference the user. Most likely you'll use their userName and tagLine in order to get their puuid for later use.

Example response:

{puuid: 'HfYckhbhJnSBzZZmcIvAJHy4Zpg9rEBeuom5gAIe60boHI7Vtb6D7pFqjIfpMdafWKEhZ0oFNUZCzA', 
gameName: 'Otzo', 
tagLine: 'NA'}

lor.getUserMatchHistory(puuid, region)

Returns matchId's for the last 20 games played by selected user.

| Parameter | Type | Example | Description | | :-------- | :------- |:------- |:------------------------ | | puuid | string | 'K-1NczBPzqHG1Ab...' | Required | | region | string | 'Americas' | Required |

Example response:

[
'bcdb95bc-beab-4e59-907d-2eff75aabd98', 
...
'7f10f485-3217-4a3b-bf22-4f63e19fb689', 
'cf36602d-215c-4a00-b0db-309f16695fed', 
'312174dd-2a52-4979-ae04-31aeed0ad7e4'
]

lor.getMatchDetails(matchId, region)

Returns match info, including: players, who won, decks played, and more.

| Parameter | Type | Example | Description | | :-------- | :------- |:------- |:------------------------ | | matchId | string | 'bcdb95bc-beab-4...' | Required | | region | string | 'Americas' | Required |

lor.getLeaderboard(region)

Returns top players in that region, including: puuid, userName, and tagLine.

| Parameter | Type | Example | Description | | :-------- | :------- |:------- |:------------------------ | | region | string | 'Americas' | Required |

lor.getLorStatus(region)

Returns current server status for that region.

| Parameter | Type | Example | Description | | :-------- | :------- |:------- |:------------------------ | | region | string | 'Americas' | Required |

Examples

Grab list of top players in the Americas

var leaderboard = await lor.getLeaderboard('Americas')
    .then((data) => {
        var json = JSON.parse(data.body)

        return json
    }) //catch errors
    .catch((err) => console.log(err));

// do stuff with data
console.log(leaderboard['players'])

Find user's PUUID by userName and tagLine

var puuid = await lor.getUserByName('Otzo', 'Otzo', 'Americas')
    .then((data) => {
        var json = JSON.parse(data.body)

        return json.puuid
    }) //catch errors
    .catch((err) => console.log(err));

//do stuff with data
console.log(puuid);

Grab list of most recently played games by user PUUID

var matches = await lor.getUserMatchHistory(puuid, 'Americas')
    .then((data) => {
        var json = JSON.parse(data.body)

        return json
    }) //catch errors
    .catch((err) => console.log(err));

//do stuff with data
console.log(matches);

Feedback

I wrote this wrapper to use in my personal project. My goal was to not only to reduce outside dependencies in my own projects, but also make the API easier to use.

Writing this wrapper introduced me to javascript prototypes, classes, publishing NPM packages, and exporting/importing ES modules.

Any and all feedback is appreciated.

🔗 Links

telegram twitter wakatime