This is a PUBG API wrapper for Node.js with built-in caching that originated from the statg discord bot. There might be better wrappers out there, but feel free to use this one if you like ;)
The composition of the objects returned by pubg-royle
match the JSON returned by the PUBG API. So be sure to read the relevant parts of the official docs.
npm install pubg-royale
Also make sure to grab a key for the PUBG API here. IMPORTANT: Keep your key secret!
const pubgRoyale = require('pubg-royale');
const client = new pubgRoyale.Client({
// Put your api key here
key: 'YOUR_KEY_HERE',
// Default region used for api calls. Defaults to "steam" if omitted.
// The region can be set for individual api calls.
defaultRegion: pubgRoyale.REGIONS.PC.STEAM,
// Specifies ttl in ms for cached objects. Any value ommited defaults to 60 seconds.
// Set every value to zero to disable caching
cache: {
player: 10 * 1000,
playerStats: 10 * 1000,
match: 10 * 1000,
status: 10 * 1000,
seasons: 10 * 1000,
},
});
client.player({ name: 'JohnDoe' })
.then((player) => {
// do something with the player
})
.catch((error) => {
// handle error
});
lifetimeStats()
which can be used to fetch lifetime stats of a playerMIT