Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including paladins-api with all npm packages installed. Try it out:

var paladinsApi = require("paladins-api")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

paladins-api v1.5.5

Wrapper for the Paladins API

Welcome to the paladins-api Wrapper!

This is a Javascript wrapper for the Paladins API to simplify making requests and handling the responses.

Current version is v1.3.1 - Changelog

Note: This wrapper is still in early stages of development. Some API methods are not yet implemented.

Navigation

Installation

1. Install the package using npm install.

npm install paladins-api --save

Setting Up

1. Import the package to your entry file. Ex. app.js

const paladins = req('paladins-api');

2. Create a new instance of the api class.

const pal = new paladins('your-dev-id', 'your-auth-key');

Note: Development credentials can be obtained by completing this application.

Creating a Session

Note: Hi-Rez has limits set in place to throttle requests and sessions. Sessions expire after 15 min so re-creating a session when needed is something that needs to be implemented by yourself.

1. Create a new session using the connect() method.

var sessionId;
pal.connect(
  "PC",
  (err, res) => {
    if (!err) {
      sessionId = res;
    }
  }
);

First we create a variable called sessionId so that we can store the session returned from the connect() method.

In the connect() method we have a call back function which returns the session in the res variable. We check for error's and then store the session into the sessionId variable.

Usage (Get a player's stats)

This example is just to demonstrate how the process works. We're going to retrieve a players statistics using the getPlayer() method.

Every method we use requires a valid session variable to be passed into the function. This is required for signature generation and validation on Hi-Rez's end.

1. Create a session using the connect() method.

2. Call the method using the sessionsId and the Player's username.

pal.getPlayer(sessionId, "PC", "HiRez", (err, res) => {
  console.log(res);
});

3. The response that gets returned is an object that we can now use in our application. In this case, we just console log to make sure it's working.

Note: Player name 'HiRez' returns an empty object because the player does not exist...

Methods

connect() - Returns a session variable that's required for all API calls.

getPlayer(session, platform, player) - Returns an object with basic player statistics.

getMatchHistory(session, platform, player) - Returns a list of the players most recent matches (50).

getMatchDetails(session, platform, match_id) - Returns details of a specific match.

getChampions(session, platform) - Returns a list of all the champions and details about them.

getItems(session, platform) - Returns all the items in the game, including cards, items etc...

getDataUsed(session, platform) - Returns an object containing resources used.

getPlayerStatus(session, platform, player) - Returns the current status of the player. (offline, in-lobby etc.)

getChampionSkins(session, platform, champ_id) - Returns all skins available for chosen champion.

getChampionRanks(session, platform, player) - Returns details of the players performance with all champions.

getPlayerLoadouts(session, platform, playerId) - Returns champion loadouts for player.

Note: More methods will be added in the future.

Links

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free