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

@leventhan/battlemetrics

v1.5.7

Published

An object-oriented BattleMetrics (API) package for NodeJS. With error handling and control checks before sending API requests.

Downloads

23

Readme

BattleMetrics

Codacy Badge

BattleMetics is an advanced rewrite of BattleMeticsAPI (Orginal author: @Curse345). An easy and open source NPM Package that allows you to do a variety of functions within BattleMetrics but much easier!

Now refactored following OO principels with checkers, error handling and documented (WIP).

TODO: Soon this repo will include all possible API requests.

Installation

This is a Node.js module.

Before installing, download and install Node.js.

const BM = require('@leventhan/battlemetrics')
npm i @leventhan/battlemetrics

Initialization

Before you start you must generate an API Key from Battlemetrics. Then you can use it as below;

// The options is NEEDED for the authentication!
const options = {
    token: process.env.TOKEN || "Your_TOKEN", // after v1.4.8 don't add Bearer!
    serverID: process.env.SerVER_ID || 'Your_SERVER_ID',
    game: process.env.GAME || 'squad'
};

// Put the options in the consturctor
const battleMetrics = new BM(options);

// Example usage using .then()
battleMetrics.getServerInfoById(battleMetrics.serverID).then(res => {
    console.log(res)
}).catch(err => {
    console.log(err)
});

// Example usage using await (should be inside async function)
const awaitExample = await battleMetrics.getServerInfoById(
		battleMetrics.serverID
	);
console.log(awaitExample);
/**
 * Example usages response would be:
 * {
 *   id: '10281405',
 *   name: '✪✪✪ GERMAN SQUAD #1 ✪✪✪ @GER-SQUAD.community',
 *   address: null,
 *   ip: '194.26.183.182',
 *   port: 7787,
 *   players: 99,
 *   maxPlayers: 100,
 *   rank: 19,
 *   location: [ 8.10812, 50.518749 ],
 *   status: 'online',
 *   details: {
 *       map: 'Narva_Invasion_v2',
 *       gameMode: 'Invasion',
 *       version: 'V2.11.0.25.64014',
 *       secure: 0,
 *       licensedServer: true,
 *       licenseId: '809942',
 *       numPubConn: 99,
 *       numPrivConn: 1,
 *       numOpenPrivConn: 1,
 *       modded: false,
 *       serverSteamId: '90153141169837065'
 *   },
 *   private: false,
 *   createdAt: '2021-02-19T13:52:06.986Z',
 *   updatedAt: '2021-11-15T19:48:42.026Z',
 *   portQuery: 27165,
 *   country: 'DE',
 *   queryStatus: 'valid'
 *   }
 */
  • token - Your BattleMetrics API Token
  • serverID - Your server's ID, can be found in the URL
  • game - Name of the game (ex.: squad, arma3, arma, etc...)

Example Usage

See test/index.js for the usage example of all existing functions.

Current Avaible Methods

  • getServerInfoById - Get server info by server ID.
  • getGameInfo - Get game information by game name.
  • getServerInfoByNameAndGame - Get all servers info by filtering by serverName AND by game name.
  • getPlayTimeHistory - Get a player's play time history for max 90 days. Every day is one dataPoint.
  • getServerPlayerInfo - Get a player's information of specific server.
  • getPlayerInfo - Get a player's information in general.
  • getBanInfoByID - Get a ban information by ban id
  • getBans - Get all bans of your token.
  • getLeaderBoard - Get the leaderboard list between two dates.
  • getGameFeatures - Get game features by game name.
  • getGameFeatureOptionsList - Get all information for the feature per feature by feature id
  • getPlayerInfoBy - Get one player information by identifier (for example by steamID, playerName, playerID, IP, GUID, etc...)
  • getPlayersInfoBy - Get multiple players information by identifiers (for example by steamID, playerName, playerID, IP, GUID, etc...)
  • coming more soon - ...