Getting Started
First thing you should do before you get started using this package is, to get your API key here. Then use something like dotenv to save it as an environment variable and keep it safe.
Note: If you decide to use dotenv
make sure to add the .env
file to your .gitignore
Installation
$ npm i --save leagueoflegends-node-api
Basic Usage
This is a basic example on how to use the API.
Require the package into your project.
const LeagueofLegends = require('leagueoflegends-api');
// or with ES6
import LeagueofLegends from 'leagueoflegends-api';
Create a new instance of the API with your API_KEY
and target region.
const lol = new LeagueofLegends(YOUR_API_KEY, 'na');
lol.findSummoner('shp corasan').then((result) =>{
console.log(result);
});
Note: All functions return aPromise
.
Result
{
"shpcorasan": {
"id": 48641392,
"name": "SHP CoraSan",
"profileIconId": 1301,
"revisionDate": 1477504931000,
"summonerLevel": 30
}
}