kuper-adrian / pubg-royale

A Node.js pubg api wrapper with built-in caching
MIT License
3 stars 3 forks source link
api javascript nodejs pubg wrapper

PUBG Royale

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 ;)

Features

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.

Install

npm install pubg-royale

Also make sure to grab a key for the PUBG API here. IMPORTANT: Keep your key secret!

Use

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
  });

Changelog

1.1.0

2.0.0

2.1.0

2.1.1

License

MIT