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

pubg-api-redis

v3.7.0

Published

Playerunknown's Battlegrounds API Wrapper

Downloads

38

Readme

npm version License: MIT

pubg-api-redis

Playerunknown's Battlegrounds API Wrapper with Redis caching.

  • The API is maintained and provided by https://pubgtracker.com and all credits go to them. Thank you :D

  • It caches all http requests for 5 minutes in Redis.

Installation

npm install -S pubg-api-redis

Usage

First, generate your development APIKEY from PUBG Tracker (https://pubgtracker.com/site-api)

const {PubgAPI, PubgAPIErrors, REGION, SEASON, MATCH} = require('pubg-api-redis');

// If no Redis configuration it wont be cached
const api = new PubgAPI({
  apikey: 'XXXXX',
  redisConfig: {
    host: '127.0.0.1',
    port: 6379,
    expiration: 300, // Optional - defaults to 300.
  },
});

api.getProfileByNickname('javilobo8')
  .then((profile) => {
    const data = profile.content;
    const stats = profile.getStats({
      region: REGION.ALL, // defaults to profile.content.selectedRegion
      season: SEASON.EA2017pre3, // defaults to profile.content.defaultSeason
      match: MATCH.SOLO // defaults to SOLO
    });
    console.log(stats);
  });

api.getAccountBySteamID('76561198084956266')
  .then((account) => {
    console.log(account);
  });

Example output with profile.getStats()

{
  "region": "eu",
  "defaultRegion": "eu",
  "season": "2017-pre3",
  "defaultSeason": "2017-pre3",
  "match": "solo",
  "lastUpdated": "2017-08-26T07:04:22.1761241Z",
  "playerName": "fak3zito",
  "performance": {
    "killDeathRatio": 3.9,
    "winRatio": 12.59,
    "timeSurvived": 172745.7,
    "roundsPlayed": 143,
    "wins": 18,
    "winTop10Ratio": 0.38,
    "top10s": 48,
    "top10Ratio": 33.57,
    "losses": 125,
    "winPoints": 1862
  },
  "skillRating": {
    "rating": 2274,
    "bestRating": 2289.04,
    "bestRank": 35
  },
  "perGame": {
    "damagePg": 412.52,
    "headshotKillsPg": 1,
    "healsPg": 2.63,
    "killsPg": 3.41,
    "moveDistancePg": 3869.1,
    "revivesPg": "0",
    "roadKillsPg": 0.02,
    "teamKillsPg": 0.01,
    "timeSurvivedPg": 1208.01,
    "top10sPg": 0.34
  },
  "combat": {
    "kills": 488,
    "assists": 34,
    "suicides": 1,
    "teamKills": 1,
    "headshotKills": 143,
    "headshotKillRatio": 0.29,
    "vehicleDestroys": 10,
    "roadKills": 3,
    "dailyKills": 20,
    "weeklyKills": 85,
    "roundMostKills": 14,
    "maxKillStreaks": 2,
    "weaponAcquired": "0"
  },
  "survival": {
    "days": 21,
    "longestTimeSurvived": 2183.97,
    "mostSurvivalTime": 2183.97,
    "avgSurvivalTime": 1208.01
  },
  "distance": {
    "walkDistance": 295931.8,
    "rideDistance": 257349.8,
    "moveDistance": 553281.6,
    "avgWalkDistance": 2069.45,
    "avgRideDistance": 1799.65,
    "longestKill": 483.63
  },
  "support": {
    "heals": 376,
    "revives": "0",
    "boosts": 427,
    "damageDealt": 58990.98,
    "dBNOs": "0"
  },
  "rankData": {
    "wins": 518,
    "rating": 263,
    "kills": 59,
    "winPoints": 518
  }
}

rankData.rating is the leaderboard position

Tests

You can run tests with your development API KEY stored in environment variable

PUBG_APIKEY=<your-api-key> npm t