Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to apiv2 #231

Open
vladislavsss1 opened this issue Feb 20, 2024 · 5 comments
Open

Move to apiv2 #231

vladislavsss1 opened this issue Feb 20, 2024 · 5 comments

Comments

@vladislavsss1
Copy link

I have 1.5k play count, but the bot tells me to play a few games and it keeps telling me this even after I've played a few times. How to solve this problem?

@spookybear0
Copy link

i've noticed this too in my own bot, it seems that if a player only has played on lazer, it's not possible to acquire their best plays through apiv1.

To fix this issue Tillerino must use apiv2.

@Tillerino
Copy link
Owner

Oh no 😆

It was a matter of time before we move to v2. I guess I'll rename this issue, then.

@Tillerino Tillerino changed the title !r doesn't work in osu!lazer Move to apiv2 Feb 28, 2024
@Ameobea
Copy link

Ameobea commented Feb 28, 2024

I recently added support for lazer scores to osutrack. Rather than do surgery on the horrible 10-year-old codebase, I created a little API proxy that handles doing the OAuth and stuff required by v2 and then exposing the hiscores in the old v1 format (as closely as possible): https://github.com/ameobea/osu-api-bridge

Idk if it will be useful as-is to you, but I did reverse engineer their currently undocumented format for v2 hiscores. It's not too complicated, but there is some nuance about when to use legacy fields or not and stuff like that. You also have to set an x-api-version header to indicate that you want lazer scores and the new response format. If you don't set it, the default behavior is to give only classic scores.

As for real docs on the v2 score stuff, there isn't much but I've heard that it's planned after talking to other devs and seems to be being worked on: ppy/osu-web#11035

Anyway, I just wanted to share that info in case it might be helpful. I've gotten back into osu recently, inspired by working on osutrack again, and I'd love to see Tillerino bot pick up my new shiny lazer hiscores :)

@Tillerino
Copy link
Owner

You had me at Cargo.toml

This looks amazing. You don't have the docker image pushed somewhere by chance?

@Ameobea
Copy link

Ameobea commented Feb 29, 2024

I just pushed it up here: us-central1-docker.pkg.dev/free-tier-164405/ameo/osu-api-bridge:latest

I'm running it with this command:

docker run \
  --name osu-api-bridge \
  --restart=always \
  -d \
  -p 4510:4510 \
  -p 4511:4511 \
  -v /opt/conf/osutrack/api-bridge-conf.yml:/opt/conf.yml \
  -e RUST_LOG=info \
 us-central1-docker.pkg.dev/free-tier-164405/ameo/osu-api-bridge:latest \
  /usr/local/bin/osu-api-bridge --config /opt/conf.yml

The config file can be the same as the default-config.yml from the repo; you just have to set your OAuth token and secret at the bottom and the rest can be left as-is.

The main service listens on port 4510; 4511 is prometheus metrics. There's only one endpoint: GET http://localhost:4510/users/4093752/hiscores?mode=0&limit=20&offset=10

It returns data as close to the format from https://osu.ppy.sh/api/get_user_best as I could get. As far as I've seen, everything matches except some 50/100/300/geki/etc. counts don't seem to exist in the same way, so those don't line up perfectly.

Lmk if you want help getting it set up or running; feel free to ping me on Discord as well.

I will say, though, that the core of this code really is quite minimal. I think there's a decent chance you'd be able to modify your bot's code to talk to the v2 API natively for hiscores without a ton of effort tbh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants