Skip to content

Type Alias: OsuFilesAPI ​

OsuFilesAPI = object

Defined in: src/index.ts:176

The API object returned by init. Each module lives under its own property. Use .get for its results (e.g. db.scores.get.byDateAfter(someDate), db.beatmaps.get.byId(id)).

This example requires Node.js.

ts
import init from 'osu-files'

const db = init('./client.realm', { readOnly: true })
db.close()

return db

Properties ​

beatmap ​

beatmap: object

Defined in: src/index.ts:263

.osu beatmap file operations (parse, serialize, extract from realm).

createFileRef() ​

createFileRef(filename, source): FileRef

Create a FileRef with validation. Content auto-hashes. Hash checked against realm if available.

Parameters ​
ParameterType
filenamestring
source{ content?: Buffer; hash?: string; }
source.content?Buffer
source.hash?string
Returns ​

FileRef

createSprite() ​

createSprite(fileRef, origin?, initialPosition?, source?): StoryboardSprite

Create a sprite from a validated file ref.

Parameters ​
ParameterType
fileRefFileRef
origin?Anchor
initialPosition?Vec2
source?StoryboardElementSource
Returns ​

StoryboardSprite

getFullData() ​

getFullData(beatmapId): OsuBeatmap | undefined

Reads a beatmap's .osu file from the files folder and parses it.

Parameters ​
ParameterType
beatmapIdstring
Returns ​

OsuBeatmap | undefined

getFullDataSet() ​

getFullDataSet(setId): BeatmapSetData | undefined

Reads all beatmaps in a set from the files folder and parses them.

Parameters ​
ParameterType
setIdstring
Returns ​

BeatmapSetData | undefined

parse() ​

parse(content): OsuBeatmap

Parses an .osu file content string into structured beatmap data.

Parameters ​
ParameterType
contentstring
Returns ​

OsuBeatmap

save() ​

save(beatmapId, beatmap): boolean

Saves a modified beatmap back to disk and updates realm references.

Parameters ​
ParameterType
beatmapIdstring
beatmapOsuBeatmap
Returns ​

boolean

serialize() ​

serialize(beatmap): string

Serializes beatmap data back to an .osu file content string.

Parameters ​
ParameterType
beatmapOsuBeatmap
Returns ​

string


beatmaps ​

beatmaps: BeatmapModule

Defined in: src/index.ts:186

Beatmap module. Use .get for results and .write to change entities.


collections ​

collections: BeatmapCollectionModule

Defined in: src/index.ts:192

Collection module. Use .get for results and the module methods to change membership.


files ​

files: FileModule

Defined in: src/index.ts:200

File module. Use .get for results and .write for file records.


integrity ​

integrity: IntegrityModule

Defined in: src/index.ts:208

Safe integrity diagnostics and explicit conservative repair.


keybindings ​

keybindings: KeyBindingModule

Defined in: src/index.ts:202

Key-binding module. Use .get for results and .write for changes.


logger ​

logger: RollbackLogger

Defined in: src/index.ts:184

Rollback logger for inspecting and reverting write operations.


metadata ​

metadata: BeatmapMetadataModule

Defined in: src/index.ts:206

Beatmap-metadata module. Use .get to read metadata.


migration? ​

optional migration?: MigrationReport

Defined in: src/index.ts:180

The report from the most recent Realm migration, if one ran.


modpresets ​

modpresets: ModPresetModule

Defined in: src/index.ts:204

Mod-preset module. Use .get for results and .write for changes.


osk ​

osk: object

Defined in: src/index.ts:253

.osk skin archive operations.

export() ​

export(skinId, outputPath): Promise<void>

Exports a skin to an .osk file on disk.

Parameters ​
ParameterType
skinIdstring
outputPathstring
Returns ​

Promise<void>

import() ​

import(filePath): Promise<ImportedSkinData>

Imports an .osk skin into the Realm database and file store.

Parameters ​
ParameterTypeDescription
filePathstringPath to the skin archive.
Returns ​

Promise<ImportedSkinData>

Imported skin identity and file count.


osr ​

osr: object

Defined in: src/index.ts:230

.osr replay operations.

computeReplayMD5() ​

computeReplayMD5(username, timestamp): string

Computes an MD5 hash for matching lazer replays by username and timestamp.

Parameters ​
ParameterType
usernamestring
timestampDate
Returns ​

string

export() ​

export(scoreId, outputPath): void

Exports a score to an .osr replay file.

Parameters ​
ParameterType
scoreIdstring
outputPathstring
Returns ​

void

import() ​

import(filePath, options?): ParsedReplay

Imports an .osr replay into the Realm database.

Parameters ​
ParameterTypeDescription
filePathstringPath to the replay.
options?OsrImportOptionsBeatmap resolution and legacy conversion options.
Returns ​

ParsedReplay

Parsed replay metadata.

importAsync() ​

importAsync(filePath, options?): Promise<ParsedReplay>

Asynchronously reads and imports an .osr replay.

Parameters ​
ParameterType
filePathstring
options?OsrImportOptions
Returns ​

Promise<ParsedReplay>

A promise for parsed replay metadata.

parse() ​

parse(buffer): ParsedReplay

Parses an .osr replay buffer without importing.

Parameters ​
ParameterType
bufferBuffer
Returns ​

ParsedReplay

parseOsr() ​

parseOsr(filePath, options?): Score

Parses an .osr replay file into a Score object without writing to realm.

Parameters ​
ParameterType
filePathstring
options?OsrImportOptions
Returns ​

Score

toBuffer() ​

toBuffer(score): Buffer

Serialises a Score into an .osr replay buffer without writing to disk.

Parameters ​
ParameterType
scoreScore
Returns ​

Buffer


osz ​

osz: object

Defined in: src/index.ts:210

.osz beatmap archive operations.

export() ​

export(setID, outputPath, options?): Promise<void>

Exports a beatmap set to an .osz file.

Parameters ​
ParameterTypeDescription
setIDstringBeatmap set UUID.
outputPathstringDestination archive path.
options?{ beatmaps?: OsuBeatmap[]; }Optional in-memory beatmap overrides.
options.beatmaps?OsuBeatmap[]-
Returns ​

Promise<void>

Throws ​

If the set or a referenced file is missing.

exportFromData() ​

exportFromData(data, outputPath): Promise<void>

Exports BeatmapSetData directly to an .osz file.

Parameters ​
ParameterType
dataBeatmapSetData
outputPathstring
Returns ​

Promise<void>

import() ​

import(filePath): Promise<BeatmapSetData>

Imports an .osz file into the Realm database and content-addressed file store.

Parameters ​
ParameterTypeDescription
filePathstringPath to the archive.
Returns ​

Promise<BeatmapSetData>

Imported set metadata and parsed beatmaps.

Throws ​

If the archive is invalid, unsafe, or filesFolderPath is missing.

realm ​

realm: RealmSession

Defined in: src/index.ts:178

Guarded Realm access for advanced callers.


rulesets ​

rulesets: RulesetModule

Defined in: src/index.ts:194

Ruleset module. Use .get to read rulesets.


rulesetSettings ​

rulesetSettings: RulesetSettingModule

Defined in: src/index.ts:196

Ruleset-settings module. Use .get to read settings.


scores ​

scores: ScoreModule

Defined in: src/index.ts:188

Score module. Use .get for results and .write to change entities.


sets ​

sets: BeatmapSetModule

Defined in: src/index.ts:190

Beatmap-set module. Use .get for results and the module methods to import or export sets.


skins ​

skins: SkinModule

Defined in: src/index.ts:198

Skin module. Use .get for results and the module methods to manage skin files.

Methods ​

close() ​

close(): void

Defined in: src/index.ts:182

Closes the Realm connection and disables rollback logging.

Returns ​

void

This example requires Node.js.

ts
import { OsuFilesAPI } from 'osu-files'

return undefined

Released under the MIT License.