2.0.2 • Published 3 years ago

node-scoresaber v2.0.2

Weekly downloads
1
License
GNU General Publi...
Repository
github
Last release
3 years ago

https://github.com/SpikeHD/node-scoresaber https://github.com/SpikeHD/node-scoresaber https://www.npmjs.com/package/node-scoresaber

node-scoresaber

A NodeJS API wrapper for https://new.scoresaber.com/

https://www.npmjs.com/package/node-scoresaber

Description

node-scoresaber is an asynchronous function-based API wrapper for scoresaber.com written in Javascript using axios. It supports viewing player stats, ranked request lists and request details, player searching, and song leaderboards and details.

Installation

Simply run npm install node-scoresaber and require it in your program:

const saber = require('node-scoresaber')

Usage

Everything is based off of functions. Internally, these functions actually return instances of classes, which used to be how you would interact with this module until v2.0.0, but now it should be much cleaner and easier to use.

* All functions are asynchronous unless otherwise mentioned

Jump to:

Functions

Players

getPlayer(id)

ParameterType
idString or Number. Usually Steam ID or Oculus ID

Returns

Return value: Object

PropertyDescription
nameUsername of the player
avatar_urlURL that points to player avatar
rankCurrent global rank
countryRankCurrent rank in their respective country
countryShort-form version of player's respective country
ppTotal PP
rolePlayer role (eg."Supporter")
badgesArray of badges the player has, and their image links
isBannedBoolean - whether player is banned
isInactiveBoolean - whether player is inactive
totalScoreTotal score earned
totalRankedScoreTotal score for ranked songs only
averageRankedAccuracyAverage ranked accuracy
playCountTotal amount of plays
rankedPlayCountTotal amount of ranked plays

searchPlayers(name)

ParameterType
nameString

Returns

Return value: Array of Objects

Each object contains:

PropertyDescription
playerIdID of player
playerNameName of player
rankCurrent global rank
ppCurrent total PP
avatarURL that points to player avatar
countryShort-form version of player's respective country
historyArray of ranking history
differenceRank difference from the last 2 weeks
getAsync function, shorthand for getPlayer() (does not require ID param)

Requests

getRequest(id)

ParameterType
idString or Number

Returns

Return value: Object

PropertyDescription
default_urlRoot scoresaber URL
requestRequest ID
songIDSong ID
requestTypeNumber, not sure what it means
descriptionRequest description
approvedBoolean - whether request has been approved
idSome other ID
difficultyNumber. Correlation: Easy -> 1, Normal -> 3, Hard -> 5, Expert -> 7, Expert+ -> 9, etc.
rankUpvotesRank upvotes
rankDownvotesRank downvotes
qatUpvotesQAT Upvotes
qatDownvotesQAT Downvotes
rankCommentsArray of rank comments
qatCommentsArray of QAT comments
DifficultiesArray of objects containing the requests other difficulties

getAllRequests() and getTopRequests()

  • No Parameters -

Returns

Return value: Array of Objects

Each object contains:

ParameterDescription
requestID of the request
songIdSong ID
weightRequest weight
nameSong name
levelAuthorNameName of the author
idSome other ID
created_atTimestamp of request creation
rankVotesObject with keys: upvotes, downvotes, myVote
qatVotesObject with keys: upvotes, downvotes, myVote
difficultiesNumber of difficulties
getAsync function, shorthand for getRequest() (does not require ID param)

Examples

Searching for and getting details of a player

const myPlayer = await saber.searchPlayers('spikehd')

if (myPlayer[0]) {
  console.log(await myPlayer[0].get())
}

Getting a player by ID

const myPlayer = await saber.getPlayer('76561198106696130')
console.log(myPlayer)

Getting a top request

const topRequests = await saber.getTopRequests()

if (topRequests[0]) {
  console.log(await topRequests[0].get())
}

Getting a request by ID

const request = await saber.getRequest('1234')
console.log(request)

Contributing

Issues, PRs, etc., are all welcome!

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago