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

battlemetrics-wrapper

v0.1.1

Published

a wrapper for the battlemetrics API based on GnomeSlayer's python version

Downloads

13

Readme

⚠️ THIS IS A VERY UNSTABLE IMPLEMENTATION DUE TO THE UNSTABILITY OF BATTLEMETRICS ITSELF ⚠️

this is an implementation of GnomeSlayer's Battlemetrics API wrapper written in JS. In general, all implementation was kept the same, with some small differences that will be documented. One of the main differences of mine and Gnome's implementation is that I won't deal with any errors. is up to you, the user to use try/catch to deal with erros. I did this because I believe that only you, the end user will know the best way to deal with errors;

Install

npm install battlemetrics-wapprer

Usage

You can use as any other js library.

import Battlemetrics from "battlemetrics-wrapper";

const bm = new Battlemetrics("yourToken");

// needs to use an async function.
(async () => {
  try {
    const userInfo = bm.player.info("usernumber"); // needs to be a number not a string
    console.dir(userInfo, { depth: null });
  } catch (err) {
    console.log(userInfo);
  }
})();

For your safety I recommend you to use a .env file and add to .gitignore file so you don't leak your token in case you publish your code online via git. for using .env files is also necessary to install dotenv with npm install dotenv

import Battlemetrics from "battlemetrics-wrapper";
import { configDotenv } from "dotenv";

configDotenv();

const { TOKEN } = process.env;
const bm = new Battlemetrics(TOKEN);

more examples can be found at examples/examples.js

Types

unfortunately due to health issues I'm only able to working in this project in a slowly pace. that doesn't mean that I'll ignore the project from now on, just that it can take a little while for me to do some things.

when my friend @gnomeslayer invited me to convert his wrapper to JS I thought that it would be a fast project.And usually would be, but due to my health it took way more than I expected. Due to that I decided to release as it is, functional, but with the typing imcomplete. all that it means is that autocomplete won't always show the proper info. the library is working as it is.

CONTRIBUTING

to contribute to this project you need to:

  • first open an issue in the issue tracker.
  • ask if you can make a PR if you wish.

That's it. I welcome contributions from the community!

Note: NO MISPELLING PR WILL BE ACCEPTED;

Contact

You can contact me on Discord, simply add me: cubiquitous or, you can join the official Battlemetrics discord and @cubiquitous there.

Want to support?

This repo will always be free, but if you want to show your support, you can donate to me directly here ko-fi