forum

[Archived] getting someone's profile picture or background image with api?

posted
Total Posts
16
Topic Starter
GDcheerios
I would like to get someones profile picture and background image for a website but it would be hard to just manually do that if I could just get maybe the player id with the api and get the background image and profile pic
Death
APIv2's /users/ endpoint (and also /me/) returns a User object that has an avatar_url and cover_url field.

https://osu.ppy.sh/docs/index.html#users
https://osu.ppy.sh/docs/index.html#user
Topic Starter
GDcheerios
do you know what it means when it gives me {"authentication":"basic"}?

I have
joe = requests.get("https://osu.ppy.sh/api/v2/me/osu")

print("test log:\n")

print(joe.text)

print("=----------=\n end of log\n")

this is just for testing for reference because all this osu api stuff is super new to me
Death
Means you are missing or have an incorrect access token in your request. In your case, you are missing an access token.
Topic Starter
GDcheerios
where do I put it?
Death
-aster
What I usually do is if I like someone's pfp and header is that I right click > "inspect element" > and then go to "sources" to find the page where osu stores its code and images.

I then toggle through the folders until I find the folder where user icons are stored and then "open the image in a new tab" to save for potential future use ^^
Dntm8kmeeatu

-aster wrote:

What I usually do is if I like someone's pfp and header is that I right click > "inspect element" > and then go to "sources" to find the page where osu stores its code and images.

I then toggle through the folders until I find the folder where user icons are stored and then "open the image in a new tab" to save for potential future use ^^
If you don't wanna use the API, you can grab those things much easier.
For avatars, you can just go to a.ppy.sh/uid?.jpg
As for covers, right clicking the element and inspecting it directly should take you right to a url in the html source. No need to go through source image folders and using trial and error.
Topic Starter
GDcheerios

Dntm8kmeeatu wrote:

-aster wrote:

What I usually do is if I like someone's pfp and header is that I right click > "inspect element" > and then go to "sources" to find the page where osu stores its code and images.

I then toggle through the folders until I find the folder where user icons are stored and then "open the image in a new tab" to save for potential future use ^^
If you don't wanna use the API, you can grab those things much easier.
For avatars, you can just go to a.ppy.sh/uid?.jpg
As for covers, right clicking the element and inspecting it directly should take you right to a url in the html source. No need to go through source image folders and using trial and error.
yes I was originally doing that, but now I am realize that manually doing that for every person that authorizes on the website would be kinda hard... So I will use death's idea.
Topic Starter
GDcheerios
alright so I put in the headers.

joe = requests.get("https://osu.ppy.sh/api/v2/GDcheerios/osu", headers={"Authorization" : "Bearer {{token}}"})

it's still giving me the error
Death
The endpoint is /api/v2/users/{user}/{mode}

If you still get an error after fixing that, your token is probably wrong. You'll likely need to do some troubleshooting for that on your own if that's the case.
Topic Starter
GDcheerios
the token is the apikey right? and if it is, does it have to be that users, or can it be mine?
Death
The token is whatever you get back from your call to the /oauth/token endpoint, where you convert the code you had into an access token. I believe this was something you asked about in a previous thread and I explained in more detail there, so you might want to check back on that?

I don't know what you are using the avatars for so I can't tell you which token to use. It kind of depends. If you are doing something like displaying the user's avatar on your website after they logged in (like how you see your avatar at the top right of the osu! website for example), you'll probably want to use the token for that user.

If you are displaying a list of users or something, you probably don't want to do what you are doing at all to be honest. Making an API request for a ton of users to get their avatar is really slow, and there are better ways to do that. I don't know your use case though and I won't claim to know the best way to do something like that even if I did.
Topic Starter
GDcheerios
https://ibb.co/wCTRfwj image
right now these are manually placed links, and since I don't fully know how to properly make requests I am using a slider module on python for the osu api, its kinda broken and I had to remove the #3 player because it sometimes won't request. but I want to make a player leaderbaord using their profile pictures and background
Death
Yeah unless you are doing some caching you probably don't want to make an API request for every person in that list. It could get quite slow and depending on how long the list is it could be quite a few unnecessary requests.

If you have people's user IDs at that point, it might just be easier to manually construct the a.ppy.sh/id links Dnt mentioned earlier for now until you have some proper solution in place (after doing some research on what the best way to do something like that would be).
Topic Starter
GDcheerios
so my big idea was that someone authorizes to the client and then their name and apikey is saved to a file which I can call different people api's for api requests connected to them.

also I can send you source code to it if you want to just have a peek.

When I said that the slider module for osu api was kinda broken, I mean when loading a web page sometimes it just results in an error because of it and sometimes it doesn't. when I figure out all of this requests stuff I will change to using that instead!

oh well I figured out that instead of data={} I will use json={} it seems to do something different
Please sign in to reply.

New reply