Data Fetching

The shieldbow client is designed to allow you to fetch data from all sources such as the static files, data dragon, and the RIOT API using a single client. It is designed to allow you to fetch anything the way you want to.

Data Dragon

Data dragon hosts files that are updated every 2 weeks (sometimes more frequently), with each patch of the game. It offers data about game objects such as champions, in-game items, runes, etc.

The code below, can be used to fetch the data using the shieldbow client about the champion - Kayn.

Fetching data from the data dragon does not require a working API key. This is all simple JSON data publicly available.

If your application needs only this, you can get away without providing a valid API Key during client construction.

You still need to provide a key, but it can just be a placeholder instead of a valid key
const kayn = await client.champions.fetch('Kayn');

Here, kayn is going to be a Champion object.

We can use this object to get any kind of data about the champion. Some examples are shown below.

console.log(kayn.name);   // Kaynconsole.log(kayn.title);  // The shadow reaper// We can also print a list of all the skins of the champion.console.log(kayn.skins.map(skin => skin.name).join(', ')); // Default, Soulhunter, Odyssey ...// Or the list of all the spells (abilities) of the champion.console.log(kayn.spells.map(spell => spell.name).join(', ')); // Reaping Slash, Blade's Reach ...// Note that the passive is not included in the spells collection.console.log(kayn.passive.name); // The Darkin Scythe

Other data dragon types

/* Items */const boots = await client.items.fetch('1001');/* Summoner spells */const flash = await client.summonerSpells.findByName('Flash');/* Rune trees */const domination = await client.runes.fetch('Domination');/* Runes */await client.runes.fetchRune('Electrocute');

Fetching data from the API.

Before moving further, make sure you have a valid API key from the RIOT API Dashboard

And also ensure that you are providing it to the client during client construction.

As stated above, the shieldbow client is designed to be easy to use. Therefore, it is just as simple to fetch any kind of data from the API as it was from data dragon.

For instance, lets try fetching the summoner data for the summoner TheDrone7 (region NA).

const summoner = await client.summoners.fetchBySummonerName('TheDrone7');

Here, we are using the client's default Summoner Manager to fetch the summoner using their summoner name.

As specified in the API docs, you can also use the summoner ID, account ID, or the puuid (referred to as playerId in shieldbow) to fetch a summoner's details.

The returned object is a Summoner object.

Again, thanks to the design choices, you can also fetch other information about the summoner, such as their league rankings, by simply using the summoner.fetchLeagueEntries() method.

const leagues = await summoner.fetchLeagueEntries();

This will return a promise that will resolve to a collection of LeagueEntry object.

A Collection is an extension of the Map builtin class.

It stores data in a key-value pair and provides additional methods to manipulate the data better.

In the returned collection of league entries, the entries are mapped using the type of queue they belong to.

For example, to get their solo queue standings, you can use the key RANKED_SOLO_5x5 or for the flex queue, RANKED_FLEX_SR.

const soloQ = leagues.get('RANKED_SOLO_5x5');const flex = leagues.get('RANKED_FLEX_SR');console.log(soloQ.tier); // IRON (or DIAMOND, etc.)console.log(flex.tier); // IRON (or DIAMOND, etc.)

Regional fetching.

Now, for no reason, lets extend the example from getting started page and compare the noob's details to the GOAT's.

If we try the following

const summoner = await client.summoners.fetchBySummonerName('hide on bush');const leagueEntry = await summoner.fetchLeagueEntries();const championMastery = summoner.championMastery;const soloQ = leagueEntry.get('RANKED_SOLO_5x5');const highest = await championMastery.highest();

Unfortunately, we will get errors because we initialized the client with the na region. But hide on bush plays in the kr region.

To avoid these errors, we can simply just provide additional options while fetching the summoner and include a region option as follows.

const summoner = await client.summoners.fetchBySummonerName('hide on bush', { region: 'kr' });const leagueEntry = await summoner.fetchLeagueEntries();const championMastery = summoner.championMastery;const soloQ = leagueEntry.get('RANKED_SOLO_5x5');const highest = await championMastery.highest();

Shieldbow, will only use the region kr when fetching the summoner and any related details.

To explain this further, lets take the above code and combine it with the code from the getting started page.

We would get

import { Client } from 'shieldbow';const client = new Client('MY_API_KEY');client  .initialize({    region: 'na' // defaults to 'na'  })  .then(async () => {    // After initialization, you can use the client to make requests    const summoner1 = await client.summoners.fetchBySummonerName('TheDrone7');    const summoner2 = await client.summoners.fetchBySummonerName('hide on bush', { region: 'kr' });    const leagueEntry1 = await summoner1.fetchLeagueEntries();    const leagueEntry2 = await summoner2.fetchLeagueEntries();    const championMastery1 = summoner1.championMastery;    const championMastery2 = summoner2.championMastery;    const soloQ1 = leagueEntry1.get('RANKED_SOLO_5x5');    const soloQ2 = leagueEntry2.get('RANKED_SOLO_5x5');    const highest1 = await championMastery1.highest();    const highest2 = await championMastery2.highest();    console.log(`Summoner name: ${summoner1.name} (level: ${summoner1.level}).`);    console.log(`SoloQ: ${soloQ1.tier} ${soloQ1.division} (${soloQ1.lp} LP).`);    console.log(`Highest champion mastery: ${highest1.champion.name} (M${highest1.level} ${highest1.points} points).`);    console.log('\n\n');    console.log(`Summoner name: ${summoner2.name} (level: ${summoner2.level}).`);    console.log(`SoloQ: ${soloQ2.tier} ${soloQ2.division} (${soloQ2.lp} LP).`);    console.log(`Highest champion mastery: ${highest2.champion.name} (M${highest2.level} ${highest2.points} points).`);  });

And it would give the output as follows.

Summoner name: TheDrone7 (level: 294).
SoloQ: BRONZE III (9 LP).
Highest champion mastery: Kayn (M7 268028 points).



Summoner name: Hide on bush (level: 593).
SoloQ: CHALLENGER I (1119 LP).
Highest champion mastery: LeBlanc (M7 497491 points).

As stated above, the client will by default use the region it was initialized with, in this case na.

Therefore, when fetching the summoner 1 - TheDrone7, the request is sent to na.

However, while fetching summoner 2 - hide on bush, the request is sent to kr, as specified.

Now when we fetch any related details for summoner 2, such as the league entry, the shieldbow client learns the summoner's region and sends the request is sent to kr automatically.

Therefore, you only need to specify the region while fetching the summoner and the related details are automatically fetched from the appropriate region.

This is also why it works fine for both summoners.

NOTE: Since the region is still set to na, the client will still send all requests without a summoner or region specified to na.

To change the default region of the client, you can simply use the following line of code.

client.region = 'na';

Which will set the default region to na. You can also use any other region similarly to change the default region of the shieldbow client.


Fetching options

The client has a few options that can be used to modify the behavior of the client while fetching data. These options need to be provided while using the client's fetch methods.

The full options object is here. For some specific fetch methods, there might be additional options.

Here is a quick summary of what these are and how to use these options.

  1. cache: Store the result of the fetched data in the cache.
  2. ignoreCache: Setting this to true will ignore the cache and skip to checking the storage.
  3. store: Store the result of the fetched data in the storage (or database).
  4. ignoreStorage: Setting this to true will ignore the storage and skip to fetching the data from the API.
  5. region: The region to fetch the data from. This is only used when fetching data from the API (example above).

All of these options are optional and can be used as needed. The defaults are defined during client initialization.

If the cache is enabled during client initialization, the default value for cache and ignoreCache is true and false respectively.

Similarly, if the storage is enabled during client initialization, the default value for store and ignoreStorage is true and false respectively.

The default value for region is the client's region.


Supported APIs

The client has other managers to fetch other kinds of data from the API.

  1. Account Manager - client.accounts.
  2. Clash Manager - client.clash.
  3. Leagues Manager - client.leagues.
  4. Match Manager - client.matches.
  5. Summoner Manager - client.summoners.
  6. Current Game Manager - client.spectator.
  7. Challenge Manager - client.challenges.

Unsupported APIs

Currently, unsupported (and unplanned) API features are:


Extending the client

Using the client with other unsupported APIs is not recommended but is possible.

For this example, we will simply fetch the match timelines.

The match API is fully supported by shieldbow. So, you can just use MatchManager to fetch the match timelines.

The shieldbow client uses an ApiHandler to fetch the data from the API. This take cares of stuff such as ratelimiting but needs additional parameters to provided proper errors when encountered.

Before you move forward however, you would have to learn about

Below is how you would use the client to fetch the match timelines.

const matchId = 'some match ID here';const response = await client.api.request(`/lol/match/v5/matches/${matchId}/timeline`, {  region: region!,  regional: true,  api: 'MATCH',  method: 'getTimeline',  params: 'Match ID: ' + matchId}).catch(error => {  // Some error ocurred while fetching the data.});if (response && response.data) {  console.log(response.data); // Logs the match timeline data.}

Here, in the additional options, we provide a ApiRequestOptions object.

If you are using Typescript, you might have to do some typescript shenanigans to get this to work as the method property is not a string, it is also strongly typed to be a valid method name.

Next steps

Next up, you can learn more about

Other than that, this is the end of the guide. Feel free to check out the API documentation for more detailed information about the package.

Also feel free to create a Github issue if you have any suggestions or questions.

If you use discord, you can always reach out to me on Riot games third party developers server. My username and tag is @TheDrone7#1624.