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

elophant

v0.2.1

Published

Library for connecting to Elophant's API and Riot's League of Legends game data.

Downloads

13

Readme

Node-Elophant API Library

Library for connecting to Elopant's API and Riot's League of Legends game data.

Install

npm install elophant

Examples

Setting up. Second argument is an options object and is optional. The region defaults to na.

var elophant = require("elophant")("SECRET_APIKEY", { region: "na" });

Every one of the Elophant api methods at your fingertips. FYI: elophant.masteryPages() === elophant.mastery_pages().

elophant.masteryPages(22452772, function(err, data) {
	if (err) console.error(err);
	else console.log(data);
});

Create new Summoner object by the summoner's name. Captures two events: ready when the base info has loaded and error if the object hits an error during load.

var fuo213 = new (elophant.Summoner)("fuo213");

fuo213.on("ready", function() {
	fuo213.leagues(function(err, data) {
		if (err) console.log(err.stack);
		else console.log(data);
	});
});

fuo213.on("error", function(err) {
	console.error(err);
});

Retrieve multiple summoners by summonerId. Option complex: true will force the callback to return an array Summoner objects instead of an array of summoner names. You can use the complex option on the method api.summoner() in the same manner.

elophant.summonerNames([ 22452772, 22519058 ], { complex: true }, function(err, summoners) {
	summoners.forEach(function(summoner) {
		console.log(summoner.name);
	});
});

Create a new Team object, similar to Summoner. The option tagOrName tells the constructor that the first argument is a tag or name of a team and not an ID.

var willbus = new (elophant.Team)("nayy", { tagOrName: true });

willbus.on("ready", function() {
	willbus.rankedStats(function(err, data) {
		console.log(err, data);
	});
});

willbus.on("error", function(err) {
	console.error(err);
});

All together now. Get Summoner and then get the first Team and get that team's ranked stats.

var fuo213 = new (elophant.Summoner)("fuo213");

fuo213.on("ready", function() {
	fuo213.summonerTeamInfo(true, function(err, teams) {
		if (err) console.log(err.stack);
		else teams[0].rankedStats(function(err, data) {
			if (err) console.log(err.stack);
			else console.log(data);
		});
	});
});

fuo213.on("error", function(err) {
	console.error(err);
});

Custom API call because why not.

var url = elophant.buildURL("na", "SECRET_APIKEY", "summoner", "fuo213");

elophant.callAPI(url, function(err, data) {
	if (err) console.error(err);
	else console.log(data);
});

API Documentation

Basic Elophant API

The following methods are standardized to Elophant's API. You can call these methods by their traditional name (ie rune_pages) or by the better formatted name (ie runePages). All callbacks take two arguments, error and data, where data is the parsed Elophant data. options is an optional Javascript object.

Options

  • region : Uses this region for the call instead of the original one passed.
  • apikey : Uses this apikey for the call instead of the original one passed.
  • complex: Only available on a few methods. Essentially forces the callback to create either Summoner or Team objects on return

Methods

Summoner Class

The Summoner class is convienent way to deal with summoner data. The constructor makes one API call to retrieve basic data (like summonerId) and then uses that to make additional calls. The base class is attached as elophant.Summoner. See the examples for proper usage.

new (elophant.Summoner)(name | summonerId | data [, options ] );

Options

  • cache, Default: true : Cache results on subsequent call. Prevents too many api calls from being made.
  • region : Uses this region for the call instead of the original one passed.
  • apikey : Uses this apikey for the call instead of the original one passed.

Methods

  • masteryPages([ callback ])
  • runePages([ callback ])
  • recentGames([ callback ])
  • leagues([ callback ])
  • summonerTeamInfo([ complex ] [, callback ]) : Set complex to true for Team objects instead of basic objects.
  • inProgressGameInfo([ callback ])
  • rankedStats([ season ] [, callback ])

Team Class

The Team class is convienent way to deal with team data. The constructor makes one API call to retrieve basic data (like teamId) and then uses that to make additional calls. The base class is attached as Team. See the examples for proper usage.

new (elophant.Team)(teamId | tagOrName | data [, options ] );

Options

  • tagOrName, Default: false : Tells the contructor that the first argument passed is a team tag or name and not a teamId.
  • cache, Default: true : Cache results on subsequent call. Prevents too many api calls from being made.
  • region : Uses this region for the call instead of the original one passed.
  • apikey : Uses this apikey for the call instead of the original one passed.

Methods

  • endOfGameStats(gameId, [ callback ])
  • rankedStats([ callback ]) : Team ranked stats (not summoner ranked stats)

Other Methods

These are some additional methods, attached directly to elophant, to help out with API calls.

  • buildURL(region, apikey [, args... ]) : Build an API URL from the region, apikey and the rest of the parameters. Pass null for any of the arguments to leave out.
  • callAPI(url, callback) : Make an API call and parse response JSON for data or error.