Skip to content

Commit

Permalink
Export the new interfaces and create documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
TTTaevas committed Nov 21, 2023
1 parent 8df8605 commit 4703820
Show file tree
Hide file tree
Showing 69 changed files with 1,041 additions and 299 deletions.
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,41 @@

[**osu-api-v2-js**](https://github.com/TTTaevas/osu-api-v2-js) is a JavaScript & TypeScript package that helps you interact with [osu!api (v2)](https://docs.ppy.sh).

While it is currently unstable as it's under pretty heavy development, documentation is available on [osu-v2.taevas.xyz](https://osu-v2.taevas.xyz/)!
It is currently unstable as it's under development, but you can find documentation on [osu-v2.taevas.xyz](https://osu-v2.taevas.xyz/) if needed!

## How to install and get started

To install the package, use a command from your package manager:

```bash
npm i osu-api-v2-js # if using npm
yarn add osu-api-v2-js # if using yarn
pnpm add osu-api-v2-js # if using pnpm
bun a osu-api-v2-js # if using bun
```

Make sure to add `"type": "module"` to your `package.json`!

To use (import) the package in your project and start interacting with the API, you may do something like that:

```typescript
// TypeScript
import * as osu from "osu-api-v2-js"

async function logUserTopPlayBeatmap(username: string) {
// Because of how the API server works, it's more convenient to use `osu.API.createAsync()` instead of `new osu.API()`!
// In a proper application, you'd use this function as soon as the app starts so you can use that object everywhere
const api = await osu.API.createAsync({id: "<client_id>", "<client_secret>"})

const user = await api.getUser({username}) // We need to get the id of the user in order to request what we want
const score = (await api.getUserScores(user, "best", 1, osu.Rulesets.osu))[0] // Specifying the Ruleset is optional
const beatmapDifficulty = await api.getBeatmapDifficultyAttributesOsu(score.beatmap, score.mods) // Specifying the mods so the SR is adapted to them

let x = `${score.beatmapset.artist} - ${score.beatmapset.title} [${score.beatmap.version}]`
let y = `+${score.mods.toString()} (${beatmapDifficulty.star_rating.toFixed(2)}*)`
console.log(`${username}'s top play is on: ${x} ${y}`)
// Doomsday fanboy's top play is on: xi - FREEDOM DiVE [FOUR DIMENSIONS] +HR (8.07*)
}

logUserTopPlayBeatmap("Doomsday fanboy")
```
49 changes: 35 additions & 14 deletions docs/assets/highlight.css
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
:root {
--light-hl-0: #AF00DB;
--dark-hl-0: #C586C0;
--light-hl-0: #795E26;
--dark-hl-0: #DCDCAA;
--light-hl-1: #000000;
--dark-hl-1: #D4D4D4;
--light-hl-2: #001080;
--dark-hl-2: #9CDCFE;
--light-hl-3: #795E26;
--dark-hl-3: #DCDCAA;
--light-hl-4: #098658;
--dark-hl-4: #B5CEA8;
--light-hl-5: #A31515;
--dark-hl-5: #CE9178;
--light-hl-6: #0000FF;
--dark-hl-6: #569CD6;
--light-hl-7: #0070C1;
--dark-hl-7: #4FC1FF;
--light-hl-2: #A31515;
--dark-hl-2: #CE9178;
--light-hl-3: #008000;
--dark-hl-3: #6A9955;
--light-hl-4: #AF00DB;
--dark-hl-4: #C586C0;
--light-hl-5: #0000FF;
--dark-hl-5: #569CD6;
--light-hl-6: #001080;
--dark-hl-6: #9CDCFE;
--light-hl-7: #267F99;
--dark-hl-7: #4EC9B0;
--light-hl-8: #0070C1;
--dark-hl-8: #4FC1FF;
--light-hl-9: #098658;
--dark-hl-9: #B5CEA8;
--light-hl-10: #000000FF;
--dark-hl-10: #D4D4D4;
--light-code-background: #FFFFFF;
--dark-code-background: #1E1E1E;
}
Expand All @@ -28,6 +34,9 @@
--hl-5: var(--light-hl-5);
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--hl-9: var(--light-hl-9);
--hl-10: var(--light-hl-10);
--code-background: var(--light-code-background);
} }

Expand All @@ -40,6 +49,9 @@
--hl-5: var(--dark-hl-5);
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--hl-9: var(--dark-hl-9);
--hl-10: var(--dark-hl-10);
--code-background: var(--dark-code-background);
} }

Expand All @@ -52,6 +64,9 @@
--hl-5: var(--light-hl-5);
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--hl-9: var(--light-hl-9);
--hl-10: var(--light-hl-10);
--code-background: var(--light-code-background);
}

Expand All @@ -64,6 +79,9 @@
--hl-5: var(--dark-hl-5);
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--hl-9: var(--dark-hl-9);
--hl-10: var(--dark-hl-10);
--code-background: var(--dark-code-background);
}

Expand All @@ -75,4 +93,7 @@
.hl-5 { color: var(--hl-5); }
.hl-6 { color: var(--hl-6); }
.hl-7 { color: var(--hl-7); }
.hl-8 { color: var(--hl-8); }
.hl-9 { color: var(--hl-9); }
.hl-10 { color: var(--hl-10); }
pre, code { background: var(--code-background); }
2 changes: 1 addition & 1 deletion docs/assets/navigation.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/assets/search.js

Large diffs are not rendered by default.

135 changes: 82 additions & 53 deletions docs/classes/API.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/classes/APIError.html

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions docs/enums/RankStatus.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/enums/Rulesets.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/functions/generateAuthorizationURL.html

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions docs/index.html

Large diffs are not rendered by default.

9 changes: 2 additions & 7 deletions docs/interfaces/Beatmap.html

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions docs/interfaces/BeatmapDifficultyAttributes.html

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions docs/interfaces/BeatmapDifficultyAttributesFruits.html

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions docs/interfaces/BeatmapDifficultyAttributesMania.html

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions docs/interfaces/BeatmapDifficultyAttributesOsu.html

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions docs/interfaces/BeatmapDifficultyAttributesTaiko.html

Large diffs are not rendered by default.

13 changes: 5 additions & 8 deletions docs/interfaces/BeatmapExtended.html

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions docs/interfaces/BeatmapExtendedWithFailtimes.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions docs/interfaces/BeatmapPack.html

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions docs/interfaces/BeatmapUserScore.html

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions docs/interfaces/BeatmapWithBeatmapset.html

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions docs/interfaces/BeatmapWithBeatmapsetChecksumMaxcombo.html

Large diffs are not rendered by default.

30 changes: 11 additions & 19 deletions docs/interfaces/Beatmapset.html

Large diffs are not rendered by default.

Loading

0 comments on commit 4703820

Please sign in to comment.