1.2.4 • Published 5 years ago

j4-api v1.2.4

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

J4-API League of Legends V3/4 Data Dragon wrapper

J4-API is written in ES2017 and compile using Babel 7. Compiled using webpack. Supports League of Legends V3/4 API (V4 coming soon).

Easy to use

import {J4} from 'j4-api';

let Example = new J4('Your Riot Api key');

// All of the requests will return as a Promise object.
// Get champion.json from cdn.
Example.DataDragon.getChampions();
Example.DataDragon.getChampionById('MasterYi');
Example.DataDragon.getChampionsByKey('11');

// Get item.json from cdn.
Example.DataDragon.getItems();
Example.DataDragon.getChampions();

Table of contents

  1. Import
  2. J4
  3. App
  4. DataDragon
    1. Data
      1. Get Champion
      2. Get Item
      3. Get Language
      4. Get Maps
      5. Get Missions
      6. Get Profile Icons
      7. Get Runes
      8. Get Stickers
      9. Get Summoner Spell
      10. Get Realms
      11. Get by IDs
    2. Image
      1. Get Champion Image
      2. Get Champion Skin
      3. More
  5. Versions

Import

import {J4, DataDragon, App, Config, LeagueApiData, DefaultConfig} from 'j4-api';

J4

let Example = new J4(apiKey, region, language, version);

// API key is a must, other (region, language, version) will uses default config
// in LeagueApiData.js
// dist/LeagueApiData.js [No compiling if edit] OR server/LeagueApiData.js [need recompiling]
let J4 = new J4('Your Riot Api key');

Example.apiKey;
Example.defaultRegion;
Example.defaultLanguage;
Example.defaultVersion;

// By Default, when J4 first constructed it also construct DataDragon and App.

Example.DataDragon;
Example.App;

// Returns a promise
Example.getItem();

// Returns a promise of mee!!
Example.App.getSummoner({summonerId: "Jimmydafuq"}, 'oce');

App

Coming soon!! :D

DataDragon

Import {DataDragon} from 'j4-api';

// Default cdn is http://ddragon.leagueoflegends.com/cdn/
// You can use your cdn by putting your cdn url in.
// Your cdn file structure must be exactly the same as Data Dragon's
// Just extract the asset file. Eg. dragontail-8.23.1.tgz and
// extract it your cdn's folder.

// Usage
let Res = new DataDragon(region, language, version, cdn);

// Use default cdn
let Res = new DataDragon('oce', 'zh_CN', '8.23.1');

// Use custom cdn
let Res = new DataDragon('oce', 'en_AU', '8.23.1', 'http://mywebsite.com/cdn');

Res.getItem().then(res => {
	console.log(res);
	// {type: "item", version: "8.23.1", basic: {…}, data: {…}, groups: Array(52), …}
});

Data

Get Champion

// add true if you want championFull.json
// by default, it's false champion.json
Res.getChampions();

Get Item

Res.getItem();

Get Language

Res.getLanguage(); // Default language is the language when construct Resource object
Res.getLanguage('zh_CN');

Get Maps

Res.getMaps();

Get Missions

Res.getMissions();

Get Profile Icons

Res.getProfileIcons();

Get Runes

Res.getRunes();

Get Stickers

Res.getStickers();

Get Summoner Spells

Res.getSummonerSpells();

Get Realms

Res.getRealms(); // Defauly region, the one use for creating this Resource object.
Res.getRealms('oce'); // Return Oceania's realms.

Get by IDs

// Res.getChampionById([id1, id2, id3]);
Res.getChampionById(['MasterYi', 'Ahri', 'Akali', 'LeeSin']).then(console.log);

// Res.getChampionByKey(key);
Res.getChampionByKey(11);

// Res.getChampionByKey([key, key1, key2]);
Res.getChampionByKey([103, 84, 64, 11]);

// Res.getItemById(id);
Res.getItemById(1001);



Res.getMapById(id);

Res.getMissionById(id);

Res.getProfileIconById(id);

Res.getStickerById(id);

Res.getSummonerSpellsById(id);

Images

Getting images will return you a URL.

Get Champion Image

// id is the Champion id
Res.getChampionImage(id);

Res.getChampionImage('MasterYi');
// http://ddragon.leagueoflegends.com/cdn/8.23.1/img/champion/MasterYi.png

Get Champion Skin

// id is the Skin id.
// Images can be found in 'img\champion'
// Champion skin image type loading, splash, tiles
// default type is splash

Res.getChampionSkinImage(id, type);

Res.getChampionSkinImage('MasterYi_0');
// http://ddragon.leagueoflegends.com/cdn/img/champion/splash/MasterYi_0.jpg

Res.getChampionSkinImage('MasterYi_0', 'loading');
// http://ddragon.leagueoflegends.com/cdn/img/champion/loading/MasterYi_0.jpg

Res.getChampionSkinImage('MasterYi_0', 'tiles');
// http://ddragon.leagueoflegends.com/cdn/img/champion/tiles/MasterYi_0.jpg

More

Res.getItemImage(id);

Res.getMapImage(id);

Res.getMissionImage(id);

Res.getPassiveImage(id);

Res.getProfileIconImage(id);

Res.getSpellImage(id);

Res.getSpriteImage(id);

Res.getStickerImage(id);

Versions

1.2.0

  • Using webpack to bundle and minify files.
  • DataDragon.getChampionByKey() now support array of champion keys as input.
  • Now includes src files.
1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.12

5 years ago

1.1.11

5 years ago

1.1.10

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago