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

botarcapi_lib

v1.1.9

Published

Lib for BotArcApi

Downloads

21

Readme

BotArcApi Lib

English | 中文

A lib for BotArcApi with Typescript.

Migration (for [email protected] or earlier users): Since 2022.4.28 BotArcAPI (now known as Arcaea Unlimited API) has changed its songinfo format. You can read Type Definition for more info.

Install

Install this package is very easy.

Use npm:

npm i botarcapi_lib

Or use yarn:

yarn add botarcapi_lib

Usage

Create API

Follow the steps below:

  1. Deploy a BotArcApi server at first. This step can just follow docs of BotArcApi.

  2. Make sure you deploy the domain name of BotArcApi, such as http://localhost:8088.

  3. Choose a BotArcApi version you like, such as v5, then input codes below in your project:

    import BotArcApi from "botarcapi_lib";
    const { BotArcApiV5 } = BotArcApi;
    const api = new BotArcApiV5("http://localhost:8088", 60000);

    ...or maybe you are using Node.js:

    const { BotArcApiV5 } = require("botarcapi_lib");
    const api = new BotArcApiV5("http://localhost:8088", 60000);

    Otherwise, maybe you want to control other request config, so you can provide AxiosRequestConfig:

    import BotArcApi from "botarcapi_lib";
    const { BotArcApiV5 } = BotArcApi;
    const api = new BotArcApiV4({
        baseURL: "http://localhost:8088",
        timeout: 60000,
        headers: {
            "Authorization": "Bearer SecretAPItoken"
        }
    });
  4. Use APIs you like.

Use API

For example, you want to check the best 30 of Nagiha0798 and print result to console, you can:

import BotArcApi from "botarcapi_lib";
const { BotArcApiV4 } = BotArcApi;
const api = new BotArcApiV4({
    baseURL: "http://localhost:8088",
    timeout: 60000,
    headers: {
        "Authorization": "Bearer SecretAPItoken"
    }
});
api.user.best30("Nagiha0798", true)
    .then(console.log)
    .catch(console.error);

...or you may like using async/await:

import BotArcApi from "botarcapi_lib";
const { BotArcApiV4 } = BotArcApi;
const api = new BotArcApiV4({
    baseURL: "http://localhost:8088",
    timeout: 60000,
    headers: {
        "Authorization": "Bearer SecretAPItoken"
    }
});

async function b30() {
    console.log(await api.user.best30("Nagiha0798", true));
}

b30();

...or you have an older version of ArcUnlimitedAPI or BotArcAPI and/or use ˋUser-Agentˋ instead of ˋtokenˋ:

import BotArcApi from "botarcapi_lib";
const { BotArcApiV4 } = BotArcApi;
const api = new BotArcApiV4({
    baseURL: "http://localhost:8088",
    timeout: 60000,
    headers: {
        "User-Agent": "SecretAPIUA"
    }
});

async function b30() {
    console.log(await api.user.best30("Nagiha0798", true));
}

b30();

Util

This library integrates some practical functions.

To use these functions, you should import command at first:

import {
  botArcApiDifficulty2DifficultyClass,
  difficultyClass2String,
  botArcApiDifficulty2String,
  formatScore
} from "botarcapi_lib";

Then you may use functions you imported.

botArcApiDifficulty2DifficultyClass

Convert BotArcApi Difficulty to Difficulty Class.

You may know, BotArcApi Difficulty is a number which >=2 and <=23. This function can convert number into an object:

{
    rating: number,
    ratingPlus?: boolean
}

This format is also used in ArcaeaDifficultyClass.

Example

import BotArcApi from "botarcapi_lib";
const {util} = BotArcApi;
console.log(util.botArcApiDifficulty2DifficultyClass(21));
// { rating: 10, ratingPlus: true }

difficultyClass2String

Convert Difficulty Class to string.

Example

import BotArcApi from "botarcapi_lib";
const {util} = BotArcApi;
console.log(util.difficultyClass2String({
    rating: 10,
    ratingPlus: true
}));
// 10+
import BotArcApi from "botarcapi_lib";
const {BotArcApiv4, util} = BotArcApi;
const api = new BotArcApiv4("http://localhost:3000");
api.song.info("gl").then(info => {
    const futureDifficultyClass = info.difficulties.filter(c => c.ratingClass === 2)[0]
    console.log(util.difficultyClass2String(futureDifficultyClass)) // 11
});

botArcApiDifficulty2String

Equals to difficultyClass2String(botArcApiDifficulty2DifficultyClass(/* arg */)). Sweet!

Example

import BotArcApi from "botarcapi_lib";
const {util} = BotArcApi;
console.log(util.botArcApiDifficulty2String(21));
// 10+

formatScore

Format score number into Arcaea score display format.

9901314 => 09'901'314

Example

import BotArcApi from "botarcapi_lib";
const {util} = BotArcApi;
console.log(util.formatScore(10001540)); // 10'001'540
console.log(util.formatScore(9993506)); // 09'993'506
console.log(util.formatScore(12987)); // 00'012'987