Skip to content

GabuTheDev/osu-api-extended

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

osu-api-extended

Usage

Installation

npm i osu-api-extended
yarn install osu-api-extended
pnpm install osu-api-extended

IF SOME ENDPOINTS NOT WORKING, dm me in discord: cyperdark#6890



You need to login only once on application start (auto renew token for v2)

API V1

You can get your api key here

const { v1, auth } = require('osu-api-extended')

const main = async () => {
  auth.set_v1(api_key)

  const data = await v1.beatmap.diff(1256136)
  console.log(data)
}

main()

API V2

You can create your client here

const { v2, auth } = require('osu-api-extended')

const main = async () => {
  const SCOPE_LIST = ['public', ...];

  // Auth via client
  await auth.login('CLIENT_ID', 'CLIENT_SECRET', SCOPE_LIST);

  // Auth via lazer credentials
  await auth.login_lazer('YOUR_LOGIN', 'YOUR_PASSWORD');

  // Auth via oauth2
  await auth.authorize_cli('CLIENT_ID', 'CLIENT_SECRET', 'CALLBACK_URL', SCOPE_LIST);

  const data = await v2.beatmap.id.details(1256136)
  console.log(data)
}

main()

V2 Auth users via page

const { v2, auth } = require('osu-api-extended');

// code example for redirect page
const redirect_page = async () => {
  const SCOPE_LIST = ['public', ...];

  const url = auth.build_url('CLIENT_ID', 'CLIENT_CALLBACK_URL', SCOPE_LIST);
  return url;
};

const callback_page = async () => {
  const user_data = await auth.authorize(code, 'GAMEMODE', 'CLIENT_ID', 'CLIENT_SECRET', 'CLIENT_CALLBACK_URL');
  return user_data;
};

V2 Discord auth helpers

// discord bot auth | REQUEIRE TO HAVE A SITE WHERE YOU'LL REDIRECT USERS AFTER AUTH
const discord_auth_link = async () => {
  const SCOPE_LIST = ['public', ...];

  const url = auth.build_url('CLIENT_ID', 'CLIENT_CALLBACK_URL', SCOPE_LIST, 'DICSORD_USER_ID');
  return url;
};

const discord_callback_page = async (code, state) => {
  const user_data = await auth.authorize(code, 'GAMEMODE', 'CLIENT_ID', 'CLIENT_SECRET', 'CLIENT_CALLBACK_URL');

  return {
    discord_user_id: state,
    user_data
  };
};

Tools

const { tools } = require('osu-api-extended')

const main = async () => {
  // Accuracy from hits
  const accuracy = tools.accuracy(300, 5, 10, 0, 0, 0, 'osu')

  // Country name from country code
  const country_name = tools.country('RU')

  // Download difficulty file
  const diff_file = tools.download.difficulty(2379651, './', '2379651')

  // Calucalute pp for a difficulty
  const pp_calc = tools.pp_calc(2379651)

  // Rank letter from hits
  const rank = tools.rank(
    {
      geki: 236,
      katu: 43,
      300: 640,
      100: 54,
      50: 5,
      0: 15
    },
    'osu'
  )

  console.log({ accuracy, country_name, diff_file, pp_calc, rank })
}

main()

Mods

const { mods } = require('osu-api-extended')

const main = async () => {
  // Mods name from mods id
  const name = mods.name(64) // DT

  // Mods id from mods name
  const id = mods.id('HDDT') // 72

  console.log({ name, id })
}

main()

Dependencies

About

Package for advanced work with "osu" api

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%