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.
import init from 'osu-files'
const db = init('./client.realm', { readOnly: true })
db.close()
return dbProperties
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
| Parameter | Type |
|---|---|
filename | string |
source | { content?: Buffer; hash?: string; } |
source.content? | Buffer |
source.hash? | string |
Returns
createSprite()
createSprite(
fileRef,origin?,initialPosition?,source?):StoryboardSprite
Create a sprite from a validated file ref.
Parameters
| Parameter | Type |
|---|---|
fileRef | FileRef |
origin? | Anchor |
initialPosition? | Vec2 |
source? | StoryboardElementSource |
Returns
getFullData()
getFullData(
beatmapId):OsuBeatmap|undefined
Reads a beatmap's .osu file from the files folder and parses it.
Parameters
| Parameter | Type |
|---|---|
beatmapId | string |
Returns
OsuBeatmap | undefined
getFullDataSet()
getFullDataSet(
setId):BeatmapSetData|undefined
Reads all beatmaps in a set from the files folder and parses them.
Parameters
| Parameter | Type |
|---|---|
setId | string |
Returns
BeatmapSetData | undefined
parse()
parse(
content):OsuBeatmap
Parses an .osu file content string into structured beatmap data.
Parameters
| Parameter | Type |
|---|---|
content | string |
Returns
save()
save(
beatmapId,beatmap):boolean
Saves a modified beatmap back to disk and updates realm references.
Parameters
| Parameter | Type |
|---|---|
beatmapId | string |
beatmap | OsuBeatmap |
Returns
boolean
serialize()
serialize(
beatmap):string
Serializes beatmap data back to an .osu file content string.
Parameters
| Parameter | Type |
|---|---|
beatmap | OsuBeatmap |
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?
optionalmigration?: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
| Parameter | Type |
|---|---|
skinId | string |
outputPath | string |
Returns
Promise<void>
import()
import(
filePath):Promise<ImportedSkinData>
Imports an .osk skin into the Realm database and file store.
Parameters
| Parameter | Type | Description |
|---|---|---|
filePath | string | Path 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
| Parameter | Type |
|---|---|
username | string |
timestamp | Date |
Returns
string
export()
export(
scoreId,outputPath):void
Exports a score to an .osr replay file.
Parameters
| Parameter | Type |
|---|---|
scoreId | string |
outputPath | string |
Returns
void
import()
import(
filePath,options?):ParsedReplay
Imports an .osr replay into the Realm database.
Parameters
| Parameter | Type | Description |
|---|---|---|
filePath | string | Path to the replay. |
options? | OsrImportOptions | Beatmap resolution and legacy conversion options. |
Returns
ParsedReplay
Parsed replay metadata.
importAsync()
importAsync(
filePath,options?):Promise<ParsedReplay>
Asynchronously reads and imports an .osr replay.
Parameters
| Parameter | Type |
|---|---|
filePath | string |
options? | OsrImportOptions |
Returns
Promise<ParsedReplay>
A promise for parsed replay metadata.
parse()
parse(
buffer):ParsedReplay
Parses an .osr replay buffer without importing.
Parameters
| Parameter | Type |
|---|---|
buffer | Buffer |
Returns
ParsedReplay
parseOsr()
parseOsr(
filePath,options?):Score
Parses an .osr replay file into a Score object without writing to realm.
Parameters
| Parameter | Type |
|---|---|
filePath | string |
options? | OsrImportOptions |
Returns
toBuffer()
toBuffer(
score):Buffer
Serialises a Score into an .osr replay buffer without writing to disk.
Parameters
| Parameter | Type |
|---|---|
score | Score |
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
| Parameter | Type | Description |
|---|---|---|
setID | string | Beatmap set UUID. |
outputPath | string | Destination 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
| Parameter | Type |
|---|---|
data | BeatmapSetData |
outputPath | string |
Returns
Promise<void>
import()
import(
filePath):Promise<BeatmapSetData>
Imports an .osz file into the Realm database and content-addressed file store.
Parameters
| Parameter | Type | Description |
|---|---|---|
filePath | string | Path to the archive. |
Returns
Promise<BeatmapSetData>
Imported set metadata and parsed beatmaps.
Throws
If the archive is invalid, unsafe, or filesFolderPath is missing.
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.
import { OsuFilesAPI } from 'osu-files'
return undefined